[vb2008] Change iFrame src in webbrowser control
Hey Folks, I'm looking to change the iframe src of an iframe in my webbrowser control using an onclick (the javascript triggers window.external.iflink()
and in VB2008 I have:
Code:
Public Sub iflink()
Dim CurrentWindow As HtmlWindow = WebBrowser1.Document.Window
For Each Frame As HtmlWindow In CurrentWindow.Frames 'Get all frames
If Frame.Name = "cf1" Then
Frame.Navigate("csc.php")
End If
Next
End Sub
However the above code doesn't seem to work, how can i target iframe id (cf1) and change its source using an onclick within the webbrowser control?
Many thanks,
n3m.
Re: [vb2008] Change iFrame src in webbrowser control
Re: [vb2008] Change iFrame src in webbrowser control
Yes, it's possible. You have to supply the fully qualified url string... Also, since you already know the frame name, you don't have to loop thru the frames collection. Try this:
Code:
Dim cf1Frame As HtmlWindow = WebBrowser1.Document.Window.Frames("cf1")
If Not cf1Frame Is Nothing Then
cf1Frame.Navigate("http://www.google.com/")
End If