怎么才能使WEB控件里target为"_blank"的链接被点击时和发现需要弹出窗口时生成新的WEB控件来显示,而不是打开一个新的IE窗口,就象TencentBrowser一样

解决方案 »

  1.   

    http://support.microsoft.com/support/kb/articles/Q184/8/76.ASP
      

  2.   

    Option Explicit
    Private mvarURL As String
    Private newURL As StringPrivate Sub Form_Load()
        Text1.Left = 30
        Text1.Top = 30
        Text1.Height = 315
        WebBrowser1.Left = 30
        WebBrowser1.Top = Text1.Top + Text1.Height + 30
        If mvarURL = "" Then
            WebBrowser1.Navigate2 "about:blank"
            Text1.Text = "about:blank"
        Else
            Text1.Text = mvarURL
            Me.Caption = mvarURL & " - Internet Explorer"
        End If
    End SubPrivate Sub Form_Resize()
        If Me.WindowState <> 1 Then
            Text1.Width = Me.ScaleWidth - Text1.Left * 2
            WebBrowser1.Width = Text1.Width
            WebBrowser1.Height = Me.ScaleHeight - Text1.Top * 2 - Text1.Height
        End If
    End SubPrivate Sub Text1_GotFocus()
        Text1.SelStart = 0
        Text1.SelLength = Len(Text1.Text)
    End SubPrivate Sub Text1_Keyup(KeyCode As Integer, Shift As Integer)
    Dim URL As String
        If KeyCode = 13 Then
            If Shift = 1 Then
                URL = "http://www." & Text1.Text & ".net"
                Text1.Text = URL
            ElseIf Shift = 2 Then
                URL = "http://www." & Text1.Text & ".com"
                Text1.Text = URL
            End If
            WebBrowser1.Navigate Text1.Text
        End If
    End SubPrivate Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
        newURL = URL
    End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
        If LCase(Text1.Text) <> "about:blank" Then
            Me.Caption = WebBrowser1.LocationName & " - Internet Explorer"
        Else
            Me.Caption = "about:blank - Internet Explorer"
        End If
    End Sub'新窗口中打开的链接会触发这个事件,此时将ppDisp设置为另一个WebBrowser对象即可。
    Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
    Dim newForm As New Form1
        newForm.URL = newURL
        newForm.Show
        Set ppDisp = newForm.WebBrowser1.Object
    End SubPublic Property Get URL() As Variant
        URL = mvarURL
    End PropertyPublic Property Let URL(ByVal vNewValue As Variant)
        mvarURL = vNewValue
    End Property
      

  3.   

    Dim newForm As New Form1
        newForm.URL = newURL你不newform啊,呵呵
      

  4.   

    能增加一个web控件元素来显示更好