winform执行javascrip源代码

时间:2014-09-12 08:58:43
【文件属性】:

文件名称:winform执行javascrip源代码

文件大小:1KB

文件格式:TXT

更新时间:2014-09-12 08:58:43

源代码 C# webbrowser winfrom javascript

string scriptline01 = @"function ShowPageInfo() {"; string scriptline02 = @" var numLinks = document.links.length; "; string scriptline03 = @" var numForms = document.forms.length; "; string scriptline04 = @" var numImages = document.images.length; "; string scriptline05 = @" var numScripts = document.scripts.length; "; string scriptline06 = @" alert(‘网页的统计结果:\r\n链接数:‘ + numLinks + "; string scriptline07 = @" ‘\r\n表单数:‘ + numForms + "; string scriptline08 = @" ‘\r\n图像数:‘ + numImages + "; string scriptline09 = @" ‘\r\n脚本数:‘ + numScripts);}"; string scriptline10 = @"ShowPageInfo();"; string strScript = scriptline01 + scriptline02 + scriptline03 + scriptline04 + scriptline05 + scriptline06 + scriptline07 + scriptline08 + scriptline09 + scriptline10; IHTMLWindow2 win = (IHTMLWindow2)webBrowser.Document.Window.DomWindow; win.execScript(strScript, "Javascript");


网友评论