我一直在嘗試從WP8的webbrowser獲取元標籤信息,但沒有成功。WP8 - 從WebBrowser獲取元標籤信息
我tryed:
var myDesc = (string)myBrowser.InvokeScript("eval", " $('meta[name=description]').attr('content');");
這...
string jsString = "";
jsString += " var metas = document.getElementsByTagName('meta'); ";
jsString += " var data = 'test'; ";
jsString += " var mLen = metas.length; ";
jsString += " for(var i=0;i<mLen;i++){ ";
jsString += " if(metas[i].getAttribute('name').toLowerCase() == 'description'){ ";
jsString += " data = metas[i].getAttribute('content'); ";
jsString += " } ";
jsString += " } ";
myBrowser.InvokeScript("eval", new string[] { jsString });
var myDesc = (string)myBrowser.InvokeScript("eval", "data;");
這...
myBrowser.InvokeScript("eval", new string[] { "var desc = document.getElementsByName('description')[0].getAttribute('content');" });
,並與所有的錯誤處理:
{System.SystemException: An unknown error has occurred. Error: 80020101. at Microsoft.Phone.Controls.NativeMethods.ValidateHResult(Int32 hr) at Microsoft.Phone.Controls.WebBrowserInterop.InvokeScript(String scriptName, String[] args) at Microsoft.Phone.Controls.WebBrowser.InvokeScript(String scriptName, String[] args) ...
有人可以幫助我嗎?
最好的問候!
同樣的錯誤: {System.SystemException:發生未知錯誤。錯誤:80020101. at Microsoft.Phone.Controls.NativeMethods.ValidateHResult(Int32 hr) at Microsoft.Phone.Controls.WebBrowserInterop.InvokeScript(String scriptName,String [] args) at Microsoft.Phone.Controls.WebBrowser.InvokeScript (String scriptName,String [] args) at xxxxxxxx.myBrowser_LoadCompleted ... –
@GabrielGómez';;}在腳本中刪除一個; ...我可以得到meta的正確信息。 – AlexisXu
不!同樣的錯誤... :( –