469,578 Members | 1,702 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

Keep Popup Window in WebBrowser control instead of a new window?

When using the WebBrowser control, is it possible to cause popup windows to
appear within the WebBrowser control itself instead of a new window?

This is what I've written in the NewWindow2 event, but I can't figure out
how to get the popup to appear in the same browser window.

In this code the user is presented with "Yes", "No" or "Cancel". Yes allows
the popup to spawn a window, No should load the popup in the same window and
Cancel should just not show the popup at all.

....also, is it possible to determine the URL that the popup is trying to
load, so it can be included in the MsgBox prompt?

'
'New window is wanting to be created
'
Private Sub web_NewWindow2(ppDisp As Object, Cancel As Boolean)
Dim Resp As Long 'Holds users response

'Ask user what to do with popup window
Resp = MsgBox("Allow popup to open a new window?", vbYesNoCancel,
"Window Popup")

Select Case Resp
Case vbNo 'No, keep in same window
'Set Display object to our current web browser object (Doesn't
work)
Set ppDisp = web.object

Case vbYes 'Yes, let new window open

Case vbCancel 'Cancel, don't open popup window
Cancel = True
End Select
End Sub
Jul 17 '05 #1
1 17690
I should qualify "Doesn't work"...

If I select "NO", the popup page should appear in the main browser window
instead of a popup window. What actually happens is that the main window
resizes & positions within my app (if the popup has sizing/positioning), but
the content does not load. I'd like to AVOID the resizing, but do load the
content into the main window.
"Noozer" <do*******@me.here> wrote in message
news:7dDqc.531018$oR5.157463@pd7tw3no...
When using the WebBrowser control, is it possible to cause popup windows to appear within the WebBrowser control itself instead of a new window?

This is what I've written in the NewWindow2 event, but I can't figure out
how to get the popup to appear in the same browser window.

In this code the user is presented with "Yes", "No" or "Cancel". Yes allows the popup to spawn a window, No should load the popup in the same window and Cancel should just not show the popup at all.

...also, is it possible to determine the URL that the popup is trying to
load, so it can be included in the MsgBox prompt?

'
'New window is wanting to be created
'
Private Sub web_NewWindow2(ppDisp As Object, Cancel As Boolean)
Dim Resp As Long 'Holds users response

'Ask user what to do with popup window
Resp = MsgBox("Allow popup to open a new window?", vbYesNoCancel,
"Window Popup")

Select Case Resp
Case vbNo 'No, keep in same window
'Set Display object to our current web browser object (Doesn't
work)
Set ppDisp = web.object

Case vbYes 'Yes, let new window open

Case vbCancel 'Cancel, don't open popup window
Cancel = True
End Select
End Sub

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by HarveyB | last post: by
1 post views Thread by Bill H | last post: by
1 post views Thread by Chris LaJoie | last post: by
11 posts views Thread by V S Rawat | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.