【发布时间】:2012-05-05 22:14:17
【问题描述】:
我正在尝试调用 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";
}
我从打电话开始
webView.InvokeScript("play", new string[0]);
但这不起作用,HRESULT: 0x80020101。我在这个主题上找到了这个http://support.microsoft.com/kb/247784,但它对我一点帮助都没有。
然后我尝试做我在多个网站上找到的示例:
webView.InvokeScript("eval", new string[] { "document.documentElement.outerHTML;");
和
webView.InvokeScript("alert", new string[] {"message"});
但是这两个都不起作用,给出了相同的 HRESULT 代码。 WebView 可以正常呈现,并且 javascript 在页面上运行良好。
在确定问题/寻找解决方案方面提供任何帮助。
编辑:似乎“警报”并且在类中声明的所有方法都不起作用。在早期的 .NET 版本中似乎有一个 InvokeMethod(..),有没有 WinRT 的替代品?
【问题讨论】:
-
我也想知道这一点,如果有人能解决这个问题或戳微软的某个人来回答这个问题,我将非常高兴。
标签: c# webview windows-runtime invokescript