【发布时间】:2014-05-12 12:02:29
【问题描述】:
我在 webview 中使用 Javascriptcore 创建了 c++ 绑定,因此我的 c++ fns.并且可以从 html 访问对象。 我已按照本教程创建这些绑定。 http://parmanoir.com/Taming_JavascriptCore_within_and_without_WebView
在重新加载页面之前,我在创建和使用绑定方面没有问题。 一旦我在我的 html 页面中调用“location.reload()”,我就会丢失所有的绑定。
示例 html 代码为:
<html>
<head>
<style type="text/css">
body {
background-color: transparent;
}
p {
color: black;
background-color: rgb(255, 0, 255);
position: absolute;
top: 0;
left: 5;
margin: 0;
padding: 0;
}
</style>
<script type="text/javascript" language="JavaScript1.4"><!--
function testDummyModule()
{
if ( window.Dummy )
{
console.log("*** Dummy ID: " + window.Dummy.id);
}
else
{
console.log("[!] Dummy not supported.");
}
}
function init()
{
console.log("Testing Dummy");
testDummyModule();
console.log("Finished testing Dummy");
location.reload();
}
</script>
</head>
<body onload="init();">
<!--<p> This Page is loading without any problems</p>
<br>-->
<div id="test"></div>
<div id="text">Test Page</div>
</body>
</html>
在调用 location.reload 后重新加载页面时,我收到错误消息:“Dummy,不支持。”
我尝试在收到 setUrl 调用后立即重新创建绑定(通过删除正在创建绑定并再次创建它们的 c++ 类),但仍然出现相同的错误。
任何线索,我怎样才能使绑定再次可用
【问题讨论】:
标签: webkit javascriptcore