Results 1 to 6 of 6

Thread: HTML code to close window

  1. #1
    Join Date
    May 2008
    Posts
    923

    HTML code to close window

    On a site on which I'm working right now, whenever a user selects something a small window pops up with a description on it. I want to put a button on this windows that says "Close this Window". Can anyone help me out and guide me the code of this?

  2. #2
    Join Date
    May 2008
    Posts
    3,971

    Re: HTML code to close window

    You can simply use the following code:

    Code:
    <input type=button value="close window" onclick="window.close()">

  3. #3
    Join Date
    May 2008
    Posts
    685

    Re: HTML code to close window

    If you would like to close a window, this JavaScript code will enable you to do just that. This JavaScript code will enable your users to close a window simply by clicking on a link.

    Place this code within your HTML code where you would like the button to appear:

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

  4. #4
    Join Date
    May 2008
    Posts
    816

    Re: HTML code to close window

    To close a window using a button:

    Code:
    <form>
    <input type="button" value="Close Window" onClick="self.close()">
    </form>
    To close a window using a (simple) link:

    Code:
    <font face="arial, helvetica" size="-2"><a href="javascript:self.close()" target="_self">Close window</a></font>
    To close a window:

    HTML Code:
    <html>
    <head>
    <title>FunctionX Tutorials</title>
    </head>
    <body>
    To close a window using a text link<br>
    <a href="javascript:window.close();">Close</a>
    </body>
    </html>

  5. #5
    Join Date
    May 2008
    Posts
    923

    Re: HTML code to close window

    Is this code browser dependent? Does it work under Firefox also?

  6. #6
    Join Date
    May 2008
    Posts
    1,196

    Re: HTML code to close window

    Below code worked for me in Firefox. Just put this code in a test page and try it:

    HTML Code:
    <html>
    <title>SSOne (JavaScript: Close Window)</title>
    <body bgcolor="#FFFFFF">
    <a href="javascript:window.close();">Close This Window</a>
    <br>
    <form>
    <input type=button value="Close This Window" onClick="javascript:window.close();">
    </form>
    </body>
    </html>

Similar Threads

  1. cannot close Logitech Webcam Help window
    By Adisa in forum Windows Software
    Replies: 2
    Last Post: 30-12-2011, 04:48 AM
  2. Close window JavaScript
    By Jensen Ackles in forum Software Development
    Replies: 6
    Last Post: 13-05-2010, 12:16 PM
  3. Problem with close window in PHP
    By Duck in forum Software Development
    Replies: 3
    Last Post: 08-04-2009, 08:57 AM
  4. Need to close All Window
    By Aakarshan.d in forum Operating Systems
    Replies: 4
    Last Post: 12-02-2009, 08:58 AM
  5. How do I get the HTML code to display as HTML code?
    By NAYASA in forum Software Development
    Replies: 3
    Last Post: 26-12-2008, 01:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,275,295.38021 seconds with 17 queries