Results 1 to 7 of 7

Thread: Closing a browser?

  1. #1

    Thread Starter
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381

    Question Closing a browser?

    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

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    When it was time to close the window, the control would use
    VB Code:
    1. Me.Page.RegisterStartUpScript("blah", myjavascriptclose)
    2.  
    3.  Private Function myjavascriptclose() As String
    4.  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.

  3. #3

    Thread Starter
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    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.

    VB Code:
    1. 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

  4. #4
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    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.

  5. #5
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    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....
    Magiaus

    If I helped give me some points.

  6. #6
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    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/pro.../sp2brows.mspx
    Last edited by nemaroller; May 3rd, 2004 at 07:09 AM.

  7. #7
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    Most of that sounds like a good idea.
    Magiaus

    If I helped give me some points.

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