Results 1 to 14 of 14

Thread: Web Browser New Window

  1. #1

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Web Browser New Window

    Is there any way i can make a link that usually opens in a new window open up in the current window?

    Because when i press certain links in the web browser i made, it opens it up in Internet Explorer, which I blocked.

    Or could i make a vb web browser my default web browser, so it will open up in a new browser, but still my browser?

    Thanks,
    Philly0494

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Web Browser New Window

    This will open up a new window in your application but not in the same window that you would want it to. I have not been able to figure that one out.
    Code:
    Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
       Dim frmWB As Form1
       Set frmWB = New Form1
    
       frmWB.WebBrowser1.RegisterAsBrowser = True
    
       Set ppDisp = frmWB.WebBrowser1.Object
       frmWB.Visible = True
    End Sub

  3. #3
    Lively Member
    Join Date
    Mar 2008
    Posts
    115

    Re: Web Browser New Window

    I created my own browser and the links work only in that browser.
    Are you using the browser engine?
    - browser engine 2.0 library.

    If so then you should have a default browser window control named similar to brwWebBrowser.
    and it uses CboAddress.Text -combo-box for addresss input.
    I think with this browser window it is autmatic.

    If you created a custom window without the browser engine It could create your problem.

    .

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Web Browser New Window

    Jabber,

    I get the impression that what you made is better than using WebBrowser control. Do you have to literally make your own callback events?

    Where do you get that library? I can't find it in my project references.
    Last edited by jmsrickland; May 17th, 2008 at 12:39 PM.

  5. #5

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Re: Web Browser New Window

    i am using the web browser with brwWebBrowser

  6. #6

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Re: Web Browser New Window

    so this isnt possible?

  7. #7
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Web Browser New Window

    Did you try #2

  8. #8

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Re: Web Browser New Window

    Quote Originally Posted by jmsrickland
    Did you try #2
    yes, and it will create a new window when it calls for a new window, but its always blank

    can i display what the new window would/should actually contain?

    Code:
    Private Sub brwWebBrowser_NewWindow2(ppDisp As Object, Cancel As Boolean)
    MsgBox ("New window detected")
    Dim frm1 As frmBrowser
    Set frm1 = New frmBrowser
    frm1.brwWebBrowser.RegisterAsBrowser = True
    
    Set ppDisp = frmBrowser.brwWebBrowser.object
    frm1.Show
    frm1.brwWebBrowser.Visible = True
    frm1.cboAddress = frmBrowser.cboAddress
    frm1.brwWebBrowser.Navigate frm1.cboAddress
    End Sub
    this works fine for making a new window inside the MDI browser with the same address as the first browser window, but i want it to go to the DESTINATION of the new window link
    Last edited by Philly0494; May 18th, 2008 at 03:14 PM.

  9. #9
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Web Browser New Window

    Do it like I showed you
    Code:
    Private Sub brwWebBrowser_NewWindow2(ppDisp As Object, Cancel As Boolean)
     MsgBox ("New window detected")
    
     Dim frm1 As frmBrowser
    
     Set frm1 = New frmBrowser
     frm1.brwWebBrowser.RegisterAsBrowser = True
    
     Set ppDisp = frm1.brwWebBrowser.object
    
     frm1.Visible = True
    End Sub

  10. #10

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Re: Web Browser New Window

    Quote Originally Posted by jmsrickland
    Do it like I showed you
    Code:
    Private Sub brwWebBrowser_NewWindow2(ppDisp As Object, Cancel As Boolean)
     MsgBox ("New window detected")
    
     Dim frm1 As frmBrowser
    
     Set frm1 = New frmBrowser
     frm1.brwWebBrowser.RegisterAsBrowser = True
    
     Set ppDisp = frm1.brwWebBrowser.object
    
     frm1.Visible = True
    End Sub
    yeah, that does less, it just opens up a blank web page, my updates the web page to the current window's address.

    i wanted the new window to load the link's address, not the current pages' address

    are you sure that it did that for you?

  11. #11
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Web Browser New Window

    That code using the same names as you use works perfect for me.

    I tested it with the following:

    vbforums.com-->Visual Basic 6 and Earlier-->File Association thread-->Click on first link in post #2.

    That code opens up that link in a new window (a whole new Form with a browser window) that belongs to my VB application

    If you are getting only a blank page then there is something else going on with your program that I don't know about.

    Try this:

    Temporarily do not use the sub brwWebBrowser_NewWindow2. Rename it or something.

    Now using your application do everything the same and see if you get a good page in a new window but it will be IE's Form, not yours.

    If you get a blank page then that should tell you something but if you get a good page then that code should also give you the same exact page but only in your app's new window. If not then I need to see the rest of your code to see if I can find what's going on.

  12. #12

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Re: Web Browser New Window

    thank you, it works now
    Last edited by Philly0494; May 18th, 2008 at 06:39 PM.

  13. #13
    Lively Member
    Join Date
    Mar 2008
    Posts
    115

    Re: Web Browser New Window

    I used browser 2.0 library.
    I got rid of the midichild stuff and I did make custom callbacks.

    it's not complete. But here is a downized image of it.
    I have it where you can set custom colors on the options page.


    http://i56.photobucket.com/albums/g1...mybroswer1.jpg

    I used my own Buttons instead of tabstrip.

    Some simple code used.
    Code:
    Private Sub Cmd1_Click() ''Starts the command Sub
     On Error GoTo a:
        brwWebBrowser.GoBack      
    a: 'Refresh
    End Sub
    
    Private Sub Cmd2_Click()
     On Error GoTo a:
        brwWebBrowser.Gofoward '' Goes back to the previous page
    a: 'Refresh
    End Sub
    
    Private Sub Cmd3_Click()
    On Error GoTo a:
        brwWebBrowser.GoHome '' Goes to the home page
    a: 'Refresh
    End Sub
    
    Private Sub Cmd4_Click()
    On Error GoTo a:
        brwWebBrowser.Refresh '' Refresh
    a: 'Refresh
    End Sub
    
    Private Sub Cmd5_Click()
    On Error GoTo a:
        brwWebBrowser.Navigate CboAddress
        CboAddress.SetFocus
    a: 'Refresh
    
    End Sub
    
    Private Sub Window_Click()
             ShellExecute hWnd, vbNullString, (App.Path & "\MyBrowser.exe"), _
               vbNullString, vbNullString, vbNormalFocus
            
    End Sub
    I misunderstood the question.
    I didnt have the link set to open new window yet.
    I do now. Thanks.
    The problem now is getting the new window to open with my preferences for the first window.
    My color scheme isn't loading.

    .
    Last edited by Jabber; May 19th, 2008 at 03:59 AM.

  14. #14
    Member MSWindowsUser's Avatar
    Join Date
    Dec 2007
    Posts
    40

    Re: Web Browser New Window

    Here is my code.

    Note: your objects can meet the requirements, but be careful. Rename if nescessary, or you'll get an error.

    Code:
    Private Function Popups() As Boolean
        Dim frmAds As Form
        Dim ppDisp As Object
        Dim Cancel As Boolean
    
        Set frmAds = New frmWebBrowser
        Set ppDisp = frmAds.WebBrowser1.Object
    
        If Popups = False Then
            Cancel = False
            frmAds.Visible = True And Fasle
            Unload frmAds
        End If
    End Function
    
    Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
        Dim frmNewWindow As Form, Popups As Boolean
        
        Set frmNewWindow = New frmWebBrowser
        Set ppDisp = frmNewWindow.WebBrowser1.Object
        WebBrowser1.RegisterAsBrowser = True
        frmNewWindow.Show
        Popups = False
    End Sub
    This code is a Popup blocker and New window opener

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