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?
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?
You can simply use the following code:
Code:<input type=button value="close window" onclick="window.close()">
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>
To close a window using a button:
To close a window using a (simple) link:Code:<form> <input type="button" value="Close Window" onClick="self.close()"> </form>
To close a window:Code:<font face="arial, helvetica" size="-2"><a href="javascript:self.close()" target="_self">Close window</a></font>
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>
Is this code browser dependent? Does it work under Firefox also?
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>
Bookmarks