九色国产,午夜在线视频,新黄色网址,九九色综合,天天做夜夜做久久做狠狠,天天躁夜夜躁狠狠躁2021a,久久不卡一区二区三区

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Implementing a PopUp blocker into a WebBrowse...

The main idea of Blocking unwanted pop-ups in that document:

Pop-ups are most of the time not very welcome, or could be inappropriate. To block these things, some additional information is needed. NewWindow3 gives this information when the user uses Windows XP SP2, or Windows 2003 SP1 or better. If this event is not fired, NewWindow2 takes its place. When NewWindow3 is fired, you can check:

  • If the user initiated the action that leads to the new window
  • If the user holds the override key (the Ctrl Key)
  • If it is a pop-up displayed because of a window that is closing
  • The URL that is going to be opened
  • And more...

Using NewWindow3 clearly is very interesting for this purpose. To use this event, DWebBrowserEvents2 needs to be implemented.

Solution:

  1. Implement DWebBrowserEvents2
  2. Create a new event and a new event arguments class
  3. Launch this event with the appropriate information
  4. After the event is fired, see if the navigation needs to be canceled

 

Hi Travy,

Here are three more intuitionistic approaches:

 

1. Use the AxWebBrowser ActiveX control, and handle AxWebBrowser_NewWindow2 event and AxWebBrowser_NewWindow3 event.

    

    Right-click the ToolBox -> select Choose Items -> Select the COM tab -> Select "Microsoft Web Browser"

   The Microsoft Web Browser control will be added in the toolbox, then drag it onto your form.

   

Code Snippet

Public Class Form1

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        AxWebBrowser1.Navigate("http://www.ccb.com")

    End Sub

 

    Private Sub AxWebBrowser1_NewWindow2(ByVal sender As System.Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NewWindow2Event) Handles AxWebBrowser1.NewWindow2

        e.cancel = True ' blocking pop up new window

    End Sub

 

    Private Sub AxWebBrowser1_NewWindow3(ByVal sender As System.Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NewWindow3Event) Handles AxWebBrowser1.NewWindow3

        e.cancel = True ' blocking pop up new window

    End Sub

 End Class

 

 

2. Use the AxWebBrowser ActiveX control, and handle AxWebBrowser_NavigateComplete2 event.

Code Snippet

Public Class Form1

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        AxWebBrowser1.Navigate("http://www.ccb.com")

    End Sub

 

    Private Sub AxWebBrowser1_NavigateComplete2(ByVal sender As System.Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event) Handles AxWebBrowser1.NavigateComplete2

        ' Get a reference to the app that has opened in AxWebBrowser1 object

        Dim oDocument As Object = e.pDisp.Document

        oDocument.parentWindow.execScript("window.alert=null; ")

        oDocument.parentWindow.execScript("window.confirm=null; ")

        oDocument.parentWindow.execScript("window.showModalDialog=null; ")

        oDocument.parentWindow.execScript("window.open=null; ")

    End Sub

End Class

 

3. Using thread to monitor Popup windows and send message to close popup window.

Code Snippet

Imports System.Runtime.InteropServices

Imports System.Threading

 

Public Class Form1

 

    Private Const WM_SYSCOMMAND As Long = &H112

    Private Const SC_CLOSE As Long = &HF060 ' Close window

 

    ' P/Invoke FindWindow API

    <DllImport("User32.dll")> _

    Public Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As Int32

    End Function

 

    ' P/Invoke SendMessage API

    <DllImport("user32.dll", CharSet:=CharSet.Auto)> _

    Public Shared Function SendMessage(ByVal hWnd As Integer, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As Integer

    End Function

 

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

         WebBrowser1.Navigate("http://www.ccb.com")

        ' Run thread

            Dim s As ThreadStart = New ThreadStart(AddressOf ClosePopup)

            Dim myThread As Thread = New Thread(s)

            myThread.Start()

    End Sub

  

    ' Send Close message to the Popup window

    Public Sub ClosePopup()

       Dim handle As IntPtr

       While True

           handle = FindWindow(Nothing, "Popup Window Title")

           If handle <> IntPtr.Zero Then

               SendMessage(wordHandle, WM_SYSCOMMAND, SC_CLOSE, 0)

           End If

       End While

    End Sub

 

End Class

Trackback: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2794291&SiteID=1

How to Maximize/Minimize/Restore/Close a window through SendMessage API?

 

 

Check this thread for reference:

http://www.msnewsgroups.net/group/microsoft.public.dotnet.languages.csharp/topic10556.aspx

Does WebBrowser control in .net 2.0 support blocking pop-up windows?

 

 

I hope that can help you.

 

 

Good luck!

Martin

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
IE webbrowser技巧集
人生如夢,你我皆過客,來去匆匆......
問一個(gè)SHDocVwCtl.WebBrowser的問題
MOX.cc [vb.net中webBrowser控件的問題?如何使彈出的網(wǎng)頁在 本身 w...
C#調(diào)用WebBrowser NewWindow
WebBrowser控件的常用方法、屬性和事件
更多類似文章 >>
生活服務(wù)
熱點(diǎn)新聞
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服