Need a close window script w/o IE message

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

harleyrider

Thread Starter
Joined
Jul 22, 2002
Messages
19
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
 
Joined
Jul 8, 2002
Messages
14,681
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.
 
M

MadDogMugsy

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
 
Joined
May 31, 2000
Messages
147
if you open the window witch you wish to close you can latter close it without the alert... best of luck
 

harleyrider

Thread Starter
Joined
Jul 22, 2002
Messages
19
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.

<a href="javascript:window.close()">Close Window</a>

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

Chris
 
Joined
May 20, 2003
Messages
1
Very simple: use vbscript

sub MyClose()
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys( "%{F4}") 'close window
end sub
 
Joined
Aug 17, 2001
Messages
7,486
If you use a vbscript, other browsers won't be able to use it. IE can read vbs, but not the others.
 
Joined
Jul 8, 2002
Messages
14,681
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.
 
Joined
Dec 26, 2002
Messages
325
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.
 
Joined
Apr 30, 2001
Messages
2,636
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.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top