【发布时间】:2014-01-09 13:08:43
【问题描述】:
我一直在尝试从 WP8 上的网络浏览器获取元标记信息,但没有成功。
我试过了:
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:发生未知错误。错误: 80020101. 在 Microsoft.Phone.Controls.NativeMethods.ValidateHResult(Int32 hr) 在 Microsoft.Phone.Controls.WebBrowserInterop.InvokeScript(字符串 脚本名称,字符串 [] 参数)在 Microsoft.Phone.Controls.WebBrowser.InvokeScript(字符串脚本名称, 字符串[] args) ...
有人可以帮帮我吗?
最好的问候!!
【问题讨论】:
标签: windows-phone-8 meta invokescript