18

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?

1
  • 1
    I'd also like to know this and would be very happy if someone can figure this out or poke at someone at Microsoft to answer this thing.
    – Akku
    Jun 14, 2012 at 13:08

1 Answer 1

30

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

2
  • Thanks, and sorry for not marking it as an answer for so long. Didn't really help in my case, sadly, because I don't control the javascript.
    – SBoss
    Feb 22, 2013 at 15:57
  • Thank you. This helped me. To be clear, this happens when there is runtime error too (in my case, using undeclared variable).
    – Luke Vo
    Apr 13, 2018 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.