WebView InvokeScript HRESULT 0x80020101

SBo*_*oss 13 c# webview invokescript windows-runtime

我正在尝试在WebView中调用一个函数.我需要调用的一些目标函数是:

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";
}
Run Code Online (Sandbox Code Playgroud)

我开始打电话

webView.InvokeScript("play", new string[0]);
Run Code Online (Sandbox Code Playgroud)

但这没用,HRESULT:0x80020101.我在这个主题上找到了这个http://support.microsoft.com/kb/247784,但它根本没有帮助我.

然后我尝试在多个站点上做我发现的示例:

webView.InvokeScript("eval", new string[] { "document.documentElement.outerHTML;");
Run Code Online (Sandbox Code Playgroud)

webView.InvokeScript("alert", new string[] {"message"});
Run Code Online (Sandbox Code Playgroud)

但是这两个都没有用,给出了相同的HRESULT代码.WebView正常呈现,javascript在页面上正常工作.

我很感激在确定问题/寻找解决方案方面提供帮助.

编辑:似乎"警告",所有在类中声明的方法都不起作用.在早期的.NET版本中似乎有一个InvokeMethod(..),WinRT还有其他选择吗?

Ant*_*ser 26

当您在javascript中出现语法错误时,会出现该错误.