WebView InvokeScript HRESULT 0x80020101

SBoss picture SBoss · Apr 25, 2012 · Viewed 17.4k times · Source

I'm trying to invoke a function in a WebView. Some target functions I need to call are these:

play: function()
{
    if (this.value < this.p.max)
    {
        this.inc();
        this.timer = new it_timer({ object: this, method: "play", timeout: 200 });
    }
    else
        this.stop();
},
stop: function()
{
    if (this.timer)
        this.timer.stop();
    this.playing = false;
    this.playbutton.style.backgroundPosition = "0 0";
}

I started by calling

webView.InvokeScript("play", new string[0]);

but that didn't work, HRESULT: 0x80020101. I found this http://support.microsoft.com/kb/247784 on the topic, but it didn't help me at all.

I then tried to do what I found as an example on multiple sites:

webView.InvokeScript("eval", new string[] { "document.documentElement.outerHTML;");

and

webView.InvokeScript("alert", new string[] {"message"});

but both of those didn't work, giving the same HRESULT code. The WebView renders normally and javascript works fine on the page.

I'd appreciate any help in identifying the problem / finding a solution.

EDIT: It seems "alert" and all methods which are declared in classes don't work. There seems to have been an InvokeMethod(..) in earlier .NET Versions, are there any alternatives for WinRT?

Answer

Anthony Wieser picture Anthony Wieser · Oct 13, 2012

That error occurs when you have a syntax error in the javascript, it appears.