#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    15
    Rep Power
    0

    avoiding the "are you sure you want to close this window" message


    I'm using a text link with the following in the href tag:

    javascript:window.close();


    What can I do to make sure the annoying "are you sure you want to close this window" message DOES NOT pop up.

    Thanks!
  2. #2
  3. #3
  4. No Profile Picture
    small, green, and connected
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    FL, SC
    Posts
    63
    Rep Power
    14
    I assume you mean you want people using your site not to get this warning? Good luck. I don't know about Internet Explorer, but I know it *is possible* in Netscape 4.x through a fantastic contortion of the javascript security model--it's not supposed to be possible.

    This is also very bad manners in web page design.

    -wg <><
  5. #4
  6. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Posts
    9
    Rep Power
    0

    closing a window without message


    You will not see the message if you spawned the window by creating it in javascript. <a target="_new"> is not the same as spawning a window:

    function popWindowLarge(documentName,windowName) {
    var szDoc = documentName;
    var nLeft = ((screen.availWidth/2)-140) - (screen.availLeft/2);
    var nTop = ((screen.availHeight/2)-170) - (screen.availTop/2);
    if(nTop.toString()=="NaN"){//ie compatibility
    nTop = 100;
    }//end if
    if(nLeft.toString()=="NaN"){
    nLeft = 100;
    }//end if
    // the key to closing the window via script is the dependent=1 arg
    // only dependent windows may be closed via script without prompting the user
    var myWindow = window.open(szDoc, windowName, "width=400,height=360,center,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=10,res izable=1,copyhistory=0,dependent=1,screenX=" + nLeft.toString() + ",screenY=" + nTop.toString() + ",top=" + nTop.toString() + ",left=" + nLeft.toString());
    if(myWindow){
    myWindow.focus();
    }//end if
    }

    this code popups a window to the specified documentName (url) and names the window as specified.

    now, this code works in the created window without a message:

    <a href="javascript:self.close();">Close Me</a>
  7. #5
  8. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    15
    Rep Power
    0
    Thanks Trabun,

    Do you know how to call up that javascript in Flash? The link that opens the windo will be in an SWF inside an HTML doc.

    Thanks!!!
  9. #6
  10. No Profile Picture
    small, green, and connected
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    FL, SC
    Posts
    63
    Rep Power
    14
    well, if I'd known we were talking about opening a window first . . . ;-)

    also, "dependent=1" should be unnecessary, as this is the default.

    -wg <><
  11. #7
  12. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Leicester, UK
    Posts
    2
    Rep Power
    0
    alternatively, if you use "window.opener=null;" then you can close without the alert everytime (on IE, not tried it on Netscape)

    function closeme(){
    window.opener = null;
    window.close();
    }

    have fun.

IMN logo majestic logo threadwatch logo seochat tools logo