
WebView 内の HTML から Titanium アプリ側へ値を渡す Titanium Mobile のサンプルです。
この記事の目次 非表示
サンプルコード
app.js
var win = Titanium.UI.createWindow();
var web = Titanium.UI.createWebView({ url: "index.html"
});
Titanium.App.addEventListener("linkClick", function(e) { alert(e.message);
});
win.add(web);
win.open();index.html
<html>
<head>
<title></title>
<script language="javascript">
function callFunc(message) { Titanium.App.fireEvent("linkClick", { message: message });
}
</script>
</head>
<body>
<a href="#" onclick="callFunc('HelloWorld');">クリック</a>
</body>
</html>開発環境
Titanium Mobile SDK 1.7.5
iOS SDK 5.0
参考にさせてもらったページ
ありがとうございます!
現場からは以上です。それでは、またッ!!!


