# Need a close window script w/o IE message



## harleyrider (Jul 22, 2002)

Hello everyone,

I'm desperately in search of a javascript that allow me to put up a close window link that will close the window without any kind of IE messages.

If there's anyone out there that can help - the next beer is on me.

Thanks in advance for any replies!
Chris


----------



## brendandonhu (Jul 8, 2002)

To show or not show the alert is in the persons security settings which you have no control over, so you can t do this.


----------



## Guest (Jan 20, 2003)

hey harley - hope this helps

I spend quite a bit of time in The JavaScript Source
http://javascript.internet.com/ 
_The JavaScript Source is an excellent JavaScript resource with tons of "cut and paste" JavaScript examples for your Web pages. All for free! _

If you do a search for close window, you will find some very interesting scripts

example:http://javascript.internet.com/page-details/closing-windows.html _This set of short, easy scripts shows six different ways to close a window from JavaScript, including closing windows from a clicked link, a clicked image, or a clicked form button. _

cheers
MDM


----------



## lunapero (May 31, 2000)

if you open the window witch you wish to close you can latter close it without the alert... best of luck


----------



## harleyrider (Jul 22, 2002)

Wanted to say thanks to all of you for replying on this subject and giving me a hand. Your time and efforts are much appreciated.

Conclusion:
After lots of research on the web from OLE Commands to Javascript, it seems impossible to get around the browser warning that the "browser is trying to close the window - YES/NO" message.

UNLESS, the close script is seated within a window that was originally a pop up window. In other words, lets say you design a page that has thumbnail pictures and you want them to pop up the larger image in a new window with a 'close window' link at the bottom. One method would be to make a page for each larger image, use a javascript to designate the url and attributes of the new window, and use the simple code below for your close window link.

Being that the larger images were opened in a new pop up window, and the close window script is located within that same window, the "browser is trying to close the window - YES/NO" message will not appear.

Close Window

Thanks again to everyone for their help, hope this info helps someone else browsing this forum.

Chris


----------



## ghrllp (May 20, 2003)

Very simple: use vbscript

sub MyClose()
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys( "%{F4}") 'close window
end sub


----------



## Mosaic1 (Aug 17, 2001)

If you use a vbscript, other browsers won't be able to use it. IE can read vbs, but not the others.


----------



## brendandonhu (Jul 8, 2002)

Yea, VBS isnt a good idea for a website unless you know its only going to be used in a controlled-environment where there is only IE.


----------



## NameTooLong (Dec 26, 2002)

Couldn't you detect the browser with JS and then run the vb if it's IE or JS if it's not IE? Opera, Netscape, and K-meleon didn't give a close window prompt. It's more complicated than it should be but if you don't want the prompt in IE this is one way to do it.


----------



## Shadow2531 (Apr 30, 2001)

view source to see how it's done

http://home.tbbs.net/shadow/tsgforums/examples/close link.htm

That will work even if the page was not opened from another page.

so if you copy the link, paste it in the address bar and load that page, you can still close it without being prompted.

It also works in Opera 7.11 and Netscape 7.02

In Mozilla 1.4b it doesn't work (don't have 1.3 at the moment)

Netscape 4.8 will still prompt you.

You could probably improve the script too.


----------

