Results 1 to 3 of 3

Thread: [vb2008] Change iFrame src in webbrowser control

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2008
    Posts
    91

    [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.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jun 2008
    Posts
    91

    Re: [vb2008] Change iFrame src in webbrowser control

    is this possible?

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    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
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width