Results 1 to 5 of 5

Thread: how to close a browser window

  1. #1
    Join Date
    Oct 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to close a browser window

    Hi,

    is there a way that I can close a browser window with some type of link inside this window? and not via its parent window?

    i want to open a window and in it, have a question of yes or no and if a user answers 'no', i would like to close the window, but i can't seem to do so.

    so my parent window has codes like this:

    <html>
    <head><title>test close html</title>
    <link rel="stylesheet" href="windowfiles/dhtmlwindow.css" type="text/css" />

    <script type="text/javascript" src="windowfiles/dhtmlwindow.js">

    /***********************************************
    * DHTML Window Widget- Dynamic Drive (www.dynamicdrive.com)
    * This notice must stay intact for legal use.
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/

    </script>
    </head>
    <body>
    this is a test html<br/><br/>
    <a href="#" onClick="googlewin.hide(); return false">Hide Window 1</a><br/><br/>

    <script type="text/javascript">
    googlewin=dhtmlwindow.open("googlebox", "iframe", "http://localhost:8080/IRS1098t/test.html", "test closing a dhtml window", "width=700px,height=450px,resize=1,scrolling=1,center=1", "recal")
    </script

    </body>
    </html>

    and my test.html looks like this:

    <html>
    <head><title>test html</title>
    </head>
    <body>
    this is a test html to test closing of the dhtml window<br/><br/>

    <a href="#" onClick="googlewin.hide(); return false">Hide Window 1</a><br/><br/>
    <a href="javascript:googlewin.hide(); return false">Hide Window 1</a><br/><br/>
    <A href="javascript:self.close()">Close this Window using self.close</A><br/><br/>
    <a href="javascript:window.opener='x';window.close();">Close using window.opener</a>


    </body>
    </html>

    as you can see, i'm trying several methods to close it but no luck.
    any help would be greatly appreciated!
    thank you.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <a href="#" onclick="parent.googlewin.hide(); return false;">Hide Window 1</a>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Oct 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    that didn't work. I think I confused you. I'm trying to click on a link (or a button) in the newly popup window to close itself, not via the parent window.

    so test_close.html opens up test.html; and I need to have test.html closed when the user clicks on a link or a button.

    thanks!!

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Please post a link to a page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Oct 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    sorry for the late reply. It worked. I was not pointing to a valid place for the javascript.
    thanks for helping me out!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •