2012-04-25 59 views
9

我想在WebView中調用一個函數。我需要調用一些目標函數是這些:WebView InvokeScript HRESULT 0x80020101

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的替代品?

+0

我也想知道這一點,如果有人能夠弄清楚這個問題或者向微軟的某人回覆這個問題,我會非常高興。 – Akku 2012-06-14 13:08:46

回答

17

當您在javascript中出現語法錯誤時,會出現該錯誤。

+1

男人,你是最棒的! – Hilmi 2013-01-27 09:45:34

+0

謝謝,很抱歉沒有把它標記爲這麼長時間的答案。可悲的是,我沒有真正幫助我,因爲我不控制JavaScript。 – SBoss 2013-02-22 15:57:04