當前位置:首頁 » 編程軟體 » webbrowser屏蔽腳本

webbrowser屏蔽腳本

發布時間: 2022-08-28 10:10:02

A. c#窗體WebBrowser控制項鏈接網頁後出現腳本錯誤,屏蔽錯誤之後網頁上的按鈕就不能用了

基本沒啥好辦法,想辦法使用WebKit內核 吧,WebBrowser會自動使用兼容IE7模式,結果就是很多現在的HTML不支持,反正我是被折磨了好久,網上那些啥改注冊表什麼地方法我都試遍了,搞不定

B. 怎樣不讓webbrowser控制項不彈出腳本錯誤提示

不過要注意的是:
ScriptErrorsSuppressed 設置為True會禁用所有的對話框,比如提示Activex下載、執行以及安全登錄等對話框。
如果不想禁止除腳本錯誤之外的對話框,請使用MSDN上的代碼示例:

private void browser_DocumentCompleted(object sender,
e)
{
((WebBrowser)sender).Document.Window.Error
+= new HtmlElementErrorEventHandler(Window_Error);
}

private void Window_Error(object sender, HtmlElementErrorEventArgs
e)
{
// Ignore the error and suppress the error dialog box.

e.Handled = true;
}

C. 用webBrowser打開網頁出現腳本錯誤怎麼辦

假設你的瀏覽器部件名為 WebBrowser1你可以這樣來屏蔽那些煩人的腳本錯誤彈窗:在打開網址之前,設置 WebBrowser1.Silent = True
這個屬性只能用代碼設置,比如在窗體啟動代碼中設置:
Private Sub Form_Load()
WebBrowser1.Silent = True
WebBrowser1.Navigate "http://www..com"
End Sub

D. vb程序WebBrowser1網頁顯示,連接論壇時彈出當前腳本錯誤,連接網站沒事,請問怎麼用代碼屏蔽彈出當前腳本

在程序中加入這句:
webbrowser.silent=true

E. vb的WebBrowser控制項怎樣避免瀏覽器腳本錯誤

啟動IE,執行「工具→Internet選項」菜單,選擇「高級」選項卡,選中「禁止腳本調試」復選框,最後單擊「確定」按鈕即可。

F. vb的WebBrowser控制項怎樣避免解決瀏覽器腳本錯誤

如果你不想屏蔽彈出錯誤,又想點擊裡面的按鈕的話,只能用spy++找到彈窗的句柄,然後發送消息點擊「是」(可以用指定位置模擬滑鼠點擊),思路:
1.放一個定時器,實時偵測有無彈窗的句柄;
2.發現句柄,找到「是」的位置,模擬發送滑鼠點擊消息。
這種方法有個缺點就是,彈窗還是會出現閃一下,出現的速度取決於你的定時器的間隔,最好將定時器的間隔設為100ms即0.1秒。
望採納!

G. webBrowser1怎樣禁止運行腳本

設置一個 TIMER

寫入以下的代碼
webbrowser1.Height =Form1.Height - 900
webbrowser1.Width = Form1.Width - 200

把Interval 屬性設置為200

H. 當用webBrowser1載入網頁的時候,網頁中出現js錯誤,會彈出一個提示,如何屏蔽不提示

WebBrowser控制項禁用超鏈接轉向、腳本錯誤提示、默認右鍵菜單和快捷鍵

從 VS2005開始,VS自帶的 WebBrowser控制項,就已經相當友好了,可控性非常高了。Winform 結合 WebBrowser 做UI開發,也是一種非常流暢的模式了, 微軟的VS IDE 系列的安裝程序, 基本都是這個模式的

禁用錯誤腳本提示
將 WebBrowser控制項的 ScriptErrorsSuppressed 設為 true

禁用右鍵菜單
將 WebBrowser 的 設為 false

禁用快捷鍵
將 WebBrowser 的 WebBrowserShortcutsEnabled 設為 false

禁用超鏈接
超鏈接分為兩種,一種是 當前窗口直接轉向, 一種是 在新窗口中打開
當然窗口直接轉向:
將 WebBrowser 的 AllowNavigation 設為 false
在新窗口中打開:

禁用新窗口打開,需要處理 WebBrowser 的 NewWindow 事件
private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
{
e.Cancel = true;
}

做完上面的工作,基本就完工了,還有最後一點需要注意,那就是 Drag-And-Drop

記得將 WebBrowser 的 AllowWebBrowserDrop 設為 false

I. 如何禁用webbrowser控制項腳本調試

在 form1 類的「initializecomponent」方法的末尾,添加以下代碼以處理「form1_load」、「form1_closed」和「axwebbrowser1_navigatecomplete2」事件:

this.axwebbrowser1.navigatecomplete2 += new axshdocvw.dwebbrowserevents2_navigatecomplete2eventhandler(this.axwebbrowser1_navigatecomplete2);
this.load += new system.eventhandler(this.form1_load);
this.closed += new system.eventhandler(this.form1_closed);

8. 將下面的代碼

private void button1_click(object sender, system.eventargs e)
{
}

替換為:

private void button1_click(object sender, system.eventargs e)
{

string strfilename;

//find the office document.
openfiledialog1.filename = "";
openfiledialog1.showdialog();
strfilename = openfiledialog1.filename;

//if the user does not cancel, open the document.
if(strfilename.length != 0)
{
object refmissing = system.reflection.missing.value;
odocument = null;
axwebbrowser1.navigate(strfilename, ref refmissing , ref refmissing , ref refmissing , ref refmissing);
}
}

public void form1_load(object sender, system.eventargs e)
{
button1.text = "browse";
openfiledialog1.filter = "office documents(*.doc, *.xls, *.ppt)|*.doc;*.xls;*.ppt" ;
openfiledialog1.filterindex = 1;
}

public void form1_closed(object sender, system.eventargs e)
{
odocument = null;
}

public void axwebbrowser1_navigatecomplete2(object sender, axshdocvw.dwebbrowserevents2_navigatecomplete2event e)
{

//note: you can use the reference to the document object to
// automate the document server.

object o = e.pdisp;

odocument = o.gettype().invokemember("document",bindingflags.getproperty,null,o,null);

object oapplication = o.gettype().invokemember("application",bindingflags.getproperty,null,odocument,null);

object oname = o.gettype().invokemember("name",bindingflags.getproperty ,null,oapplication,null);

messagebox.show("file opened by: " + oname.tostring() );
}

注意:您必須在 visual studio 2005 中更改此代碼。默認情況下,當您創建 windows 窗體項目時,visual c# 向該項目添加一個窗體。該窗體被命名為 form1。表示該窗體的兩個文件被命名為 form1.cs 和 form1.designer.cs。您在 form1.cs 中編寫代碼。windows 窗體設計器在 form1.designer.cs 文件中編寫代碼,這些代碼實現通過從工具箱拖放控制項所執行的所有操作。

熱點內容
php的特點與優勢 發布:2025-02-08 02:43:16 瀏覽:716
微信公眾號怎麼上傳pdf 發布:2025-02-08 02:42:41 瀏覽:345
安卓如何查看通話總時長 發布:2025-02-08 02:27:49 瀏覽:578
快速dct演算法 發布:2025-02-08 02:19:04 瀏覽:622
淘寶交易密碼如何改 發布:2025-02-08 02:17:32 瀏覽:774
php的進階 發布:2025-02-08 02:17:28 瀏覽:675
伺服器關閉中或IP地址錯誤 發布:2025-02-08 02:16:55 瀏覽:479
節目腳本是什麼 發布:2025-02-08 02:08:54 瀏覽:143
android的自定義屬性 發布:2025-02-08 02:07:27 瀏覽:608
怎麼看電腦的用戶名和密碼 發布:2025-02-08 02:02:48 瀏覽:796