1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Need a close window script w/o IE message

Discussion in 'Software Development' started by harleyrider, Jan 20, 2003.

Thread Status:
Not open for further replies.
Advertisement
  1. harleyrider

    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
     
  2. brendandonhu

    brendandonhu

    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.
     
  3. MadDogMugsy

    MadDogMugsy Guest

    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
     
  4. lunapero

    lunapero

    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
     
  5. harleyrider

    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
     
  6. ghrllp

    ghrllp

    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
     
  7. Mosaic1

    Mosaic1

    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.
     
  8. brendandonhu

    brendandonhu

    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.
     
  9. NameTooLong

    NameTooLong

    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.
     
  10. Shadow2531

    Shadow2531

    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.
     
  11. Sponsor

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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/114297

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice