Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WebBrowser Question 3

Status
Not open for further replies.

LPlates

Programmer
Jun 5, 2003
554
AU
If I place my mouse over a link in the WebBrowser Control and right click on the page I can select 'Open in new window'

I can prevent this occuring with...

Private Sub WB1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
End Sub

What I am trying to do is obtain the URL that the 'New Window' will navigate to, any ideas anyone?
 
Try this:

Option Explicit

Dim WithEvents NewWebBrowser As WebBrowser_V1

Private Sub Form_Load()
WB1.Navigate2 " Set NewWebBrowser = WB1.Object
End Sub
Private Sub NewWebBrowser_NewWindow(ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String, Processed As Boolean)
Processed = True
Debug.Print URL
End Sub



Be sure to remove this:
Private Sub WB1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
End Sub
 
Very nice and Thankyou, what about getting the URL from mousehover over a link?
 

That would be the StatusTextChange event
[tt]
Private Sub WB_StatusTextChange(ByVal Text As String)
Debug.Print Text
End Sub
[/tt]

I belive

Good Luck

 
You'll kick yourself...

One of the other events of the class used by DrJavaJoe is StatusTextChange, so as an example:
[tt]
Private Sub WB1_StatusTextChange(ByVal Text As String)
If Left(Text, 4) = "http" Then 'is it a simple URL?
Debug.Print Text
End If
End Sub
 
Drat - my reflexes are too slow in the wake of Xmas and the New Year...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top