问题
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