Legacy browser compatible window.close()



  • On the project I'm maintaining:

     > Header.asp:

    [...] <a href="closeThisWindow.asp">Leave</a> [...]
     

    > CloseThisWindow.asp:

    <%@ Language=VBScript %>
    <html>
    <head>
    </head>
    <body>
    <script language="JavaScript">
        window.close();
    </script>
    </body>
    </html>

     

    Well, I guess it makes sense in a way.. If you click the link and you have javascript disabled, it goes to a blank page - so there, you left. 🙂

    (note the importance of being an ASP page with language=VBScript) 



  • <%

    Session.Abandon
    Response.Cookies.Clear

     %>



  • While you may see this as a WTF, the solution shown here gets around IE7's annoying popups about "A script is trying to close this window. Do you want to close it?" (or whatever it says).

    So it seems that IE7 ignores the closing event if the URL of the window has changed based on an event produced by the user (ie: clicking the Close Window link).

    BTW, there aren't many websites left that work without Javascript.



  • @X-Cubed said:

    BTW, there aren't many websites left that work without Javascript.

    Actually, most will work without it. I've been using noscript for years. 



  • @X-Cubed said:

    BTW, there aren't many websites left that work without Javascript.

    I really hope you aren't a web developer. 



  • @asuffield said:

    @X-Cubed said:

    BTW, there aren't many websites left that work without Javascript.

    Actually, most will work without it. I've been using noscript for years. 

    For a given value of 'Work'

    I've been using NoScript for about 3 months and while it's fantastic, quite a few of my regular sites don't work properly without enabling javascript on them. And when somebody posts an interesting link to something on one of the myriad of little tinpot blog sites out there, quite often I am left with a blank or half rendered page or links that don't actually link.

    Damn javascript junkies, why can't a link just be a link!
     



Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.