0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Swift WKWebViewでWebViewのTableの行クリックからネイティブへデータを受け取る

Last updated at Posted at 2022-07-10

Webのテーブルリストの行をクリックしてSwift側でその行の必要なデータをネイティブデータとして取得する例。

<script type="text/javascript">
//actvline変数初期値設定
let actvline="line1";

const OnButtonClick = function(ukeid) {
//下記記述でswift側にデータ渡し          
window.webkit.messageHandlers.callbackHandler.postMessage(String(ukeid));
}

//下記関数は
const dispxx= function(oj) {
document.all.item(actvline).style.backgroundColor="#ffffff";
document.all.item(oj.id).style.backgroundColor="#ee82ee";
actvline=oj.id;	
}
</script>


<thead>
    <TR>
      <th class="wid1">検体名称</th>
            <th class="wid3">動物種</th>
            <th class="wid1">受付区分</th>
            <th class="wid3">カルテNO</th>
            <th class="wid3">結果編集</th>
          </TR>    
</thead>
<tbody>
<tr id="line1" bgcolor="#ffffff"  onclick="dispxx(this)">
<td align="left" onclick="OnButtonClick(2531)"><a href="msginp_test_app.php?petid=76595">田中/コロ</a></td>
<td align="center" onclick="OnButtonClick(2531)">犬</td>
<td align="center" onclick="OnButtonClick(2531)">診察受付</td>
<td align="center" onclick="OnButtonClick(2531)">12345X</td>
<td align="center" onclick="OnButtonClick(2531)"><a href="ukeupd2_app.php?calmsgid=2531">編集</a></td>
</tr>
<tr id="line2" bgcolor="#ffffff"  onclick="dispxx(this)">
<td align="left" onclick="OnButtonClick(2530)"><a href="msginp_test_app.php?petid=67861">コバヤシ/ロン</a></td>
<td align="center" onclick="OnButtonClick(2530)">犬</td>
<td align="center" onclick="OnButtonClick(2530)">診察受付</td>
<td align="center" onclick="OnButtonClick(2530)">123</td>
<td align="center" onclick="OnButtonClick(2530)"><a href="ukeupd2_app.php?calmsgid=2530">編集</a></td>
</tr></tbody></table>
<BR>
</section>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?