我尝试以编程方式打开包含此网页中比特率信息的隐藏div:http://www.myfreemp3.cc/mp3/jamie+jones+cookie+monster
我正在使用隐藏的WebBrowser,我在其中注入并执行此代码:
$("[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");
答案 0 :(得分:1)
这是因为WebBrowser是旧IE的基本组件,您可以在注册表中输入设置来运行您的webbrowser以使用您计算机中的最新Internet Explorer,看一下此链接
Will the IE9 WebBrowser Control Support all of IE9's features, including SVG?
答案 1 :(得分:0)
您是否尝试过将其附加到document.head而不是document.head?
...汤姆