By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,726 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.