我正在尝试以编程方式打开此网页中包含比特率信息的隐藏 div:http://www.myfreemp3.cc/mp3/jamie+jones+cookie+monster
我正在使用隐藏的网络浏览器,我在其中注入(inject)并执行以下代码:
$("[class^='bitrate butt bit']")[0].click();
但它不起作用。
如果您将上面的代码行放入 Firefox 调试器的控制台中,它就可以工作...
这是我的代码:
webBrowser.Navigate("http://www.myfreemp3.cc/mp3/jamie+jones+cookie+monster");
waitTillLoad(webBrowser); //wait till the document finish to load
string script = "function click_checkButtons () { $(\"[class^='controll_button playlist_button']\").click(); }";
HtmlElement head = webBrowser.Document.GetElementsByTagName("head")[0];
HtmlElement scriptEl = webBrowser.Document.CreateElement("script");
IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement;
element.text = script;
head.AppendChild(scriptEl);
webBrowser.Document.InvokeScript("click_checkButtons");
最佳答案
这是因为网页浏览器是旧版 IE 的基本组件,您可以在注册表中输入设置来运行您的网页浏览器,以使用您计算机中的最新 Internet Explorer,请查看此链接
Will the IE9 WebBrowser Control Support all of IE9's features, including SVG?
关于javascript - jquery 不适用于具有特定网页的 WebBrowser 控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26205143/