Använder Ms Internet Controls och går till en hemsida där jag klickar på en länk som öppnar en ny hemsida, "NewWindow" hur får jag detta fönster att visas i huvudfönster, jag vill alltså inte få en popup window. Hitta detta exempel på Internet men det funkar bara ibland.Förhindra popupfönster i Microsoft Internet Controls & VB6.
Private Sub WebBrowser_NewWindow2(ppDisp As Object, Cancel As Boolean)
If chkPopupwin.Value <> 0 Then
Cancel = True 'Här stoppar jag det nya fönstret men vill få det i första fönstret.
End If
End Sub
Tacksam för hjälp!Sv: Förhindra popupfönster i Microsoft Internet Controls & VB6.
Dim sLink As String
WebBrowser.Document.parentWindow.event.Type = "MenuExtUnknown"
If Not WebBrowser.Document Is Nothing Then
If Not WebBrowser.Document.parentWindow.event Is Nothing Then
'If WebBrowser.Document.parentWindow.event.Type = "MenuExtUnknown" Then
' CONTEXT MENU - NAVIGATE
' Get the URL of the source Element
sLink = WebBrowser.Document.parentWindow.event.srcElement.href
Debug.Print "Context Menu: " & sLink
If Len(sLink) > 0 Then
' Cancel New Window
Cancel = True
' Force open in current window
WebBrowser.Navigate sLink
End If
'End If
Else
If WebBrowser.Document.activeElement Is Nothing Then
' PROBABLE OnLoad SCRIPT - BLOCK
Debug.Print "Probable Script: Unknown"
Cancel = True
Else
sLink = WebBrowser.Document.activeElement.href
If Len(sLink) > 0 Then
If WebBrowser.Document.activeElement.protocolLong = "Unknown Protocol" Then
' PROBABLE SCRIPTED LINK - ALLOW - *** SET NEW FORM
Cancel = False
Else
' LINK WITH EXTERNAL TARGET - NAVIGATE
Debug.Print "External Link Target: " & sLink
Cancel = True
WebBrowser.Navigate sLink
End If
Else
' UNKNOWN NEW WINDOW
Debug.Print "Unknown Reason: -"
Cancel = True
End If
End If
End If
Else
' PROBABLE SCRIPT - BLOCK
Cancel = True
End If
Tacksma för hjälp!