PDA

View Full Version : javascript:window.close()");


annadiego
11-08-2007, 04:06 PM
Hi eveyrone, I have a quick question for the experts!

I was using this javascript code for my exit window and it was working until I upgraded my IE to 7. Now..... is not working. :confused:

on (release) {
getURL ("javascript:window.close()");
}

Anybody who can help me will be very much appreciated and worship as always LOL ;)

Thank you

jefgibso
11-08-2007, 05:31 PM
Are you testing locally? I have had two issues before when using that.

First, when I test from my local hard disk, the code window.close() does not work but when I upload that same file to a website or localhost it works fine.

Second, I usually have to add window.opener = self; before the window.close();

jefgibso
11-08-2007, 05:32 PM
Oh, 1 more small thing.

You may find it better to have:

function mycloser(){
window.opener = self;
window.close();
}

Then use getURL("javascript:mycloser();");

jibbering_squid
11-10-2007, 05:49 PM
Hi, Anna

Don't know if you ever figured this out, but I ran into the same problem.

Security changes in IE7 cause the old method of getting rid of the close message to no longer work. This is what I found, and it works perfectly:

window.open('','_self','');
window.close();

More info if you need it...

http://dotnetslackers.com/community/blogs/haissam/archive/2007/04/20/Javascript_3A00_-Close-window-without-the-prompt-message-in-IE7.aspx

atomic
11-10-2007, 06:58 PM
My 2 cents...

I really hate it when someone attempts to close my main browser window, and I'm sure I'm not the only one!

Leave my main browser window alone!