本文介绍了WP7 浏览器控件不会调用 javascript 错误 80020101的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下几点:

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

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

当用户按下网页上的按钮时触发脚本通知.我正在尝试调用下面的 JavaScript,但我不断收到错误 80020101.

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>

推荐答案

80020101 表示编译准备执行的函数有问题.
问题是 appendChild() 期望传递一个节点,而您给它一个字符串.

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.

试试这个:

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

您也可以直接访问callbackDiv:

callbackDiv.appendChild(b);

这篇关于WP7 浏览器控件不会调用 javascript 错误 80020101的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 11:57