SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: window.close()

  1. #1
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    window.close()

    Code:
     
     
    <a href="javascript:window.close();">Close This Window</a>
    How do I do it without the stupid thing prompting me?

  2. #2
    SitePoint Addict hurricane.uk's Avatar
    Join Date
    May 2003
    Location
    Liverpool
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the parent window is still open (assuming the window was opened with a script) then the message shouldn't appear. Alternative is
    <script>
    function closeMe() {
    window.opener = self;
    window.close();
    }
    </script>

  3. #3
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Archbob
    Code:
     
     
    <a href="javascript:window.close();">Close This Window</a>
    How do I do it without the stupid thing prompting me?
    If it's the primary window opened (i.e. not opened via a "target=_blank" link or a if it's not a popup), you will always get the prompt. It's just a reminder to the visitor: "Hey, you sure you want to stop?".

  4. #4
    SitePoint Wizard aaron.martone's Avatar
    Join Date
    Feb 2003
    Location
    Florida, USA
    Posts
    2,322
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I think it's to help stop malicious websites from closing windows they didn't open.

  5. #5
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I think I know how to do it know.

    Thanks guys.

  6. #6
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    moved to more appropriate forum...
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com


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
  •