WP7 browser control won't invoke javascript Error 80020101

一世执手 提交于 2019-12-12 03:09:58

问题


I have the following:

public MainPage()
{
    webBrowser1.ScriptNotify += new EventHandler<NotifyEventArgs>(webBrowser1_ScriptNotify);
}

void webBrowser1_ScriptNotify(object sender, NotifyEventArgs e)
{
    // ... some code ...
    webBrowser1.InvokeScript("nativeCallback", response.Serialize());
}

The script notify is triggered when a user presses a button on the web page. I am trying to invoke the JavaScript below but i keep getting Error 80020101.

<script type="text/javascript">
    function nativeCallback(e){
        document.getElementById('callbackDiv').appendChild("<b>" + e + "</b>");
    }
</script>

回答1:


80020101 means that there is a problem compiling the function ready to execute it.
The problem is that appendChild() is expecting a node to be passed and you're giving it a string.

Try this instead:

<script type="text/javascript"> 
    function nativeCallback(e){ 
          var b = document.createElement('b');
          b.innerHTML = e;
          document.getElementById('callbackDiv').appendChild(b);
    } 
</script> 

You can also access callbackDiv directly:

callbackDiv.appendChild(b);


来源:https://stackoverflow.com/questions/9501058/wp7-browser-control-wont-invoke-javascript-error-80020101

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!