Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Close Window button in jsp

  • 05-06-2007 04:37PM
    #1
    Registered Users, Registered Users 2 Posts: 1,559 ✭✭✭


    Ive tried using the code below to make a close window button in a jsp but when I press it it doesnt do anything and the window remains open.

    <form method="post">
    <input type="button" value="Close Window" onclick="window.close()">
    </form>

    It works ok with ie but wont work with firefox.


Comments

  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    In firefox window.close() will only work for windows opened with window.open() IIRC.


  • Moderators, Politics Moderators, Paid Member Posts: 44,042 Mod ✭✭✭✭Seth Brundle


    JSP (and Java) is NOT JavaScript


  • Registered Users, Registered Users 2 Posts: 1,559 ✭✭✭quinnd6


    Im using javascript within a jsp and know the difference between them cheers.
    Here's something else I tried and didn't work

    <head>
    <script language="javascript" type="text/javascript">


    var browserName=navigator.appName;
    if (browserName=="Netscape")
    {
    function closeWindow()
    {
    window.open('','_parent','');

    window.close();
    }


    }
    else
    {
    if(browserName = "Microsoft Internet Explorer")
    {
    function closeWindow()
    {
    window.close();
    }
    }
    }
    </script>


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    I doubt you'll get anything working in Firefox.


Advertisement