Results 1 to 16 of 16

Thread: Problem with popup in webbrowser element?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    12

    Problem with popup in webbrowser element?

    Hello everyone,

    I've a question about the webbrowser control.
    I open a link in the webbrowser element where a loginname and password automaticly is filled in.
    After some automatics clicks of some links (all in one webbrowser element) i have one link that's opent in a new window.
    Thats normal because on the site they tell you that it must be opent in a new screen.

    Now i was wondering is there no way to put that popup screen also in the same webbrowser element?

    I hope its to understand what i mean, because my english is not so good.

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: Problem with popup in webbrowser element?

    Hi,

    Welcome to the forums. Can you post the code also?

    KGC
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    12

    Re: Problem with popup in webbrowser element?

    Witch code do you need? the one of the website or my vb code?

  4. #4
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: Problem with popup in webbrowser element?

    Your vb code and the website link if it's possible. So other members can look at it.

    Don't forget to wrap your code with code tags.

    KGC
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    12

    Re: Problem with popup in webbrowser element?

    That is just a small problem, it is a website of the national Government where a butcher shop needs to login.
    So i have in the code his password and login and all his links.
    I don't think he shell be happy if i post those things of him.

    Every thing i have working , but the popup screen gives me the problem, i want that also in the same webbrowser element, but in the html code there is no link to find to go to that screen.

  6. #6
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    PA
    Posts
    365

    Re: Problem with popup in webbrowser element?

    Does the webbrowsers NewWindow event not work for your case? If not...

    The popup windows do in fact have an event attached to them. It just so happens that some of the "new window" popups need to be dealt with accordingly using another system dll rather than just the plain old webbrowser methods.

    Take a look into "SHDocVW", specifically the NewWindow3 event. Try it out and let us see how you do. If you still need help post some relevant code (minus links/passwords/usernames/etc).

  7. #7

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    12

    Re: Problem with popup in webbrowser element?

    the code thats opends the popup is this code.:
    Code:
    <input id="A0059:customStartFormulierenForm:j_idt9:0:j_idt12" type="submit" name="A0059:customStartFormulierenForm:j_idt9:0:j_idt12" value="Runderen aan- en afmelden" class="openAppButton" onclick="mojarra.ab(this,event,'action',0,'A0059:customStartFormulierenForm:j_idt9:0:startApp',{'onevent':handleDoubleClick,'dienstNaamKort':'IRIMD'});return false">
    I also take a look at what you're pointing to.
    Do you have a link for me about the "SHDocVW"?
    Last edited by pascal.bianca; Sep 23rd, 2014 at 08:48 AM.

  8. #8
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    PA
    Posts
    365

    Re: Problem with popup in webbrowser element?


  9. #9

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    12

    Re: Problem with popup in webbrowser element?

    Yeah i found it after i posted the question.
    I thought it was something special but i found it in the system32 map.
    I searched internet for the problem what i asked but can't find nothing , so i realy don't know how to start.

  10. #10
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    PA
    Posts
    365

    Re: Problem with popup in webbrowser element?

    Sigh again...

    I mentioned to look into the NewWindow 3 event. Let's do a search on that: here...

  11. #11

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    12

    Re: Problem with popup in webbrowser element?

    I searched and tryed some of the codes with NewWindow ,but everything without succes.
    I thought below code was the solution but also no succes.

    Code:
      axBrowser = CType(WebBrowser1.ActiveXInstance, SHDocVw.WebBrowser)
            AddHandler axBrowser.NewWindow3, AddressOf getTheUrl
        End Sub
    
        Dim axBrowser As SHDocVw.WebBrowser
    
        Private Sub getTheUrl(ByRef ppDisp As Object, ByRef Cancel As Boolean, dwFlags As UInteger, bstrUrlContext As String, bstrUrl As String)
            MsgBox(bstrUrl)
        End Sub
    update.:

    i tryed another code.:

    Code:
    Public Class Form1
        Dim webBrowser As WebBrowser = New WebBrowser()
    
        Sub New()
            MyBase.New()
            Me.InitializeComponent()
            webBrowser.Dock = DockStyle.Fill
            Me.Controls.Add(webBrowser)
            webBrowser.Visible = True
        End Sub
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Me.webBrowser.DocumentText = "<a target='_blank' href='javascript:""<button onclick=\""window.close()\"">Close</button>""'>Go</a>"
    
            Dim ActiveX As SHDocVw.WebBrowser = Me.webBrowser.ActiveXInstance
            AddHandler ActiveX.NewWindow2, AddressOf WebBrowser_ActiveX_NewWindow2
        End Sub
    
        Private Sub WebBrowser_ActiveX_NewWindow2(ByRef ppDisp As Object, ByRef Cancel As Boolean)
            Dim popup As RawBrowserPopup = New RawBrowserPopup()
            popup.Visible = True
            ppDisp = popup.WebBrowser.ActiveXInstance
        End Sub
    End Class
    
    Public Class RawWebBrowser
        Inherits System.Windows.Forms.AxHost
    
        Sub New()
            MyBase.New("8856f961-340a-11d0-a96b-00c04fd705a2")
        End Sub
    
        Event Initialized(sender As Object, e As EventArgs)
    
        Protected Overrides Sub AttachInterfaces()
            RaiseEvent Initialized(Me, New EventArgs())
        End Sub
    
        Public ReadOnly Property ActiveXInstance() As Object
            Get
                Return MyBase.GetOcx()
            End Get
        End Property
    End Class
    
    Public Class RawBrowserPopup
        Inherits System.Windows.Forms.Form
    
        Dim WithEvents rawBrowser As RawWebBrowser = New RawWebBrowser()
    
        Sub New()
            MyBase.New()
            rawBrowser.Dock = DockStyle.Fill
            Me.Controls.Add(rawBrowser)
            rawBrowser.Visible = True
        End Sub
    
        Public ReadOnly Property WebBrowser() As Object
            Get
                Return rawBrowser
            End Get
        End Property
    
        Private Sub rawBrowser_Initialized(sender As Object, e As EventArgs) Handles rawBrowser.Initialized
            Dim activeX As SHDocVw.WebBrowser = rawBrowser.ActiveXInstance
            AddHandler activeX.NewWindow2, AddressOf activeX_NewWindow2
            AddHandler activeX.WindowClosing, AddressOf activeX_WindowClosing
        End Sub
    
        Private Sub activeX_NewWindow2(ByRef ppDisp As Object, ByRef Cancel As Boolean)
            Dim popup As RawBrowserPopup = New RawBrowserPopup()
            popup.Visible = True
            ppDisp = popup.WebBrowser.ActiveXInstance
        End Sub
    
        Private Sub activeX_WindowClosing(IsChildWindow As Boolean, ByRef Cancel As Boolean)
            Cancel = True
            Me.Close()
        End Sub
    
    End Class
    I used most of the code and now it opens in a new form, so thats look a bit better but could it be possible to put it into the first webbrowser element where the other links are loaded?
    Last edited by pascal.bianca; Sep 23rd, 2014 at 02:15 PM.

  12. #12

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    12

    Re: Problem with popup in webbrowser element?

    I've still no luck , i tryed also to get the sended url thats come from the click but that i also cannot get it to work.

  13. #13
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    PA
    Posts
    365

    Re: Problem with popup in webbrowser element?

    I used most of the code and now it opens in a new form, so thats look a bit better but could it be possible to put it into the first webbrowser element where the other links are loaded?
    At least you are on the right track... Are you sure yours is firing the NewWindow2 event instead of 3? I'm sure you could probably redirect your original webbrowser rather than creating a new browser?

    Here is inside of my NewWindow3 event if it helps:
    Code:
    Cancel = true;
                webBrowser1.Navigate(bstrUrl);

  14. #14

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    12

    Re: Problem with popup in webbrowser element?

    If i look into my code , the NewWindow2 event is fired.
    But i see you have after the webbrowser1.navigate the word bstrUrl , but i can't get this in my code.
    How do you call bstrUrl, or what i mean is how do you descripe this?

  15. #15
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    PA
    Posts
    365

    Re: Problem with popup in webbrowser element?

    That was from the NewWindow3 event which is why I asked if the 2 or 3 event was being fired for you. I'm sure there are ways to get a redirect from NewWindow2 to your current browser since you apparently open it in a new browser.

  16. #16

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    12

    Re: Problem with popup in webbrowser element?

    May i ask how you did write the code (example), maybe i see a solution to the one i have?
    I realy dod'nt know how to go further to get the url, i'm sorry i tryed everything.

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