Click to See Complete Forum and Search --> : Closing a browser?
ARPRINCE
Apr 27th, 2004, 04:10 PM
How do I code (VB) a button web control so that when it is pressed, it would close the browser? It is basically doing the same thing as when you click on the "X" button on the upper right hand side corner of IE.
TIF
nemaroller
Apr 27th, 2004, 06:21 PM
When it was time to close the window, the control would use
Me.Page.RegisterStartUpScript("blah", myjavascriptclose)
Private Function myjavascriptclose() As String
dim s as String = "<script type=""javascript"">self.close();</script>"
As soon as the page posts back to the client, it will close the browser window.
btw: The script in myjavascriptclose may be wrong and will give you a javascript error when the page loads, but you can search the internet for the proper script.
ARPRINCE
Apr 28th, 2004, 08:06 AM
Thank for your reply. I tried the code but I can't see this RegisterStartUpScript as an option for the me.page. If I type it in, it gets an underline.
Anyway, I did some research and I found that I can use this code on the page_load event.
Button1.Attributes("onclick") = "return window.close();"
It does the trick (closes the browser) but some issues for my use:
(1) There's always a prompt that informs user that the browser is being closed. How not to show this?
(2) Does not work when used in frames. Amy ideas how to use the code to close a FRAMED page?
TIF
nemaroller
Apr 29th, 2004, 07:01 AM
The prompt you cannot get around, unless you first open a blank window for your web app, then use window.open(), and use that script inside the second window that was opened. Because you programatically opened the second window, your code can have permission to close it.
Basically, if there is only one browser window... and it is trying to close, most browsers warn the user that page is trying to close.
I don't use frames in my apps, so I wouldn't know how to solve that problem. To me, there is really no reason to use frames ever, so don't bother implementing them.
Magiaus
May 2nd, 2004, 08:26 PM
what about the fact the using a menu frame and a content frame means you only have one menu file? or the fact that it hides the information about the page being viewed from the user browsing the site? or what if you want to provide a gui the streatches with browser and works for netscape and ie? or....
nemaroller
May 3rd, 2004, 06:56 AM
The concern I would have about developing frames is the security accesses the up-level browsers are putting between frames, and especially now that IE6 is getting an upgrade with the release of XP SP2, which puts further security restrictions on what you can do between frames.
As far as side-menu's and only having one menu file, you can still use custom or composite controls for the side-menu (as I know you are aware), and use styled tables to place the menus, banners, and main content. And you can still cache the side-menu control in effect giving you frame functionality, albeit on the server side, where its more secure and more easily managed.
(edit): found the list of changes that will affect web programmers developing toward the next version of IE6:
http://www.microsoft.com/technet/prodtechnol/winxppro/maintain/sp2brows.mspx
Magiaus
May 3rd, 2004, 10:19 AM
Most of that sounds like a good idea.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.