Results 1 to 5 of 5

Thread: Make a clicked link opened in the same webbrowser

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2011
    Posts
    105

    Make a clicked link opened in the same webbrowser

    I have WebBrowser1 with a loaded page. When I click on a link in WebBrowser1, (in Internet Explorer it will be a PopUp / New Screen) I want it to display in the same webbrowser (WebBrowser1) or if this isn't possible, in WebBrowser2.

    Anyone who can help me?

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Make a clicked link opened in the same webbrowser

    Not sure what is wrong here but if you have a link in a web browser in a windows form unless the target attribute is set to _blank the link opens in the same browser.

    So in the example below the first link opens in WebBrowser1 while the second link opens in the default browser i.e. Internet Explorer
    Code:
    Public Class Form3
        Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim Contents = _
            <html>
                <body>
                    <p>
                        <a href="http://www.google.com/"
                            title="opens in same window">Google</a><br/>
                        <a href="http://www.google.com/"
                            target="_blank" title="opens in a popup window">Google</a>
                    </p>
                </body>
            </html>
    
            WebBrowser1.DocumentText = Contents.ToString
        End Sub
    End Class

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2011
    Posts
    105

    Re: Make a clicked link opened in the same webbrowser

    Quote Originally Posted by kevininstructor View Post
    Not sure what is wrong here but if you have a link in a web browser in a windows form unless the target attribute is set to _blank the link opens in the same browser.

    So in the example below the first link opens in WebBrowser1 while the second link opens in the default browser i.e. Internet Explorer
    Code:
    Public Class Form3
        Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim Contents = _
            <html>
                <body>
                    <p>
                        <a href="http://www.google.com/"
                            title="opens in same window">Google</a><br/>
                        <a href="http://www.google.com/"
                            target="_blank" title="opens in a popup window">Google</a>
                    </p>
                </body>
            </html>
    
            WebBrowser1.DocumentText = Contents.ToString
        End Sub
    End Class
    I'll explain it step for step what I mean, because I think you don't understand it (I'm dutch so sorry for the bad english)

    1: I click on Button1
    2: WebBrowser1 loads URL1
    3: After 2/3 seconds, LINK1 on the page is automatically clicked (I coded this already with ivokemember and link-id)
    4: The link is going to a URL2 that if you use an normal browser, will open in a new window. But in the program, it will open in WebBrowser1 (or WebBrowser2 if the other one isn't possible)

  4. #4
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Make a clicked link opened in the same webbrowser

    The problem is not the web browser control but something you have done which you are not showing thus since we are not mind readers have no idea how to assist you.

  5. #5
    Junior Member
    Join Date
    Jan 2012
    Location
    United Kingdom
    Posts
    20

    Re: Make a clicked link opened in the same webbrowser

    Sorry to bump an old thread but I was browsing because I have a very similar problem I am new to this so I'm sorry if I don't supply something I should but here goes

    I am in the process of creating an automatic account creator as I'm into marketing etc so I needed a project to learn with and turned from a bit of fun now I'm totally addicted to VB and learning more and more but back to the point I have automated all of the process up until when I click on the link sent in the verification email it automatically opens in internet explorer (which is actually not my default browser so another reason why it really surprised me).

    I have done a lot of research into why its opening in IE and not the same window and I am guessing it has something to do with you you place links and can tell them to open in a new window???

    Is there a way I can override or stop links from opening using web browser control or something I have looked at so many topics and have found lots of similar problems with web pages opening in IE/default browser. I am using VB 2010

    The email provider I am using for email verification is www.incognitomail.com and it is a Twitter verification email

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