Welcome to WebmasterWorld Guest from 54.161.25.142

Forum Moderators: open

Message Too Old, No Replies

how to insert a close button/link on a small pop up window

     
7:33 am on Nov 16, 2004 (gmt 0)

10+ Year Member



There is a small window that opens on load of my home page and it stays there for 10 secs and closes on its own after 10 secs .... is there a simple code taht i can insert in m html so that the visitors have the option to close the window if they want to before the 10 secs?

Help Please

12:02 pm on Nov 16, 2004 (gmt 0)

10+ Year Member



Not tested but should get you started

Somewhere where you have your Javascript insert

function clswin() {
close();}

Then you can call the clswin function using something like

<a onclick="clswin();" href="#"><IMG border="0" src="images/close_1.jpg"></a>

making sure that your image is referenced correctly or using appropriate text.

12:32 pm on Nov 16, 2004 (gmt 0)

10+ Year Member



Or: (Looks like a button)

<button onclick="self.close();">Close Me</button>

Or: (Looks like a link)

<a href="#" onclick="self.close();">Close Me</a>

Or: (Looks like plain text)

<a onclick="self.close();">Close Me</a>

Or for that matter, if you put the "onclick=" in your <body> tag, clicking anywhere in the small window will close it.

<body onclick="self.close();">

12:57 pm on Nov 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The <button> tag is not completely compatible with all browsers. try this:

<input type=button onClick="if(window.opener){window.close()}else{alert('This page is not being displayed as a popup.')}">

7:32 am on Nov 18, 2004 (gmt 0)

10+ Year Member



Or: (Looks like a link)

<a href="#" onclick="self.close();">Close Me</a>



I tried to insert this link on the small window (this is a script that i am using - which shows a small pop up type of page over my original page which closes automatically in 10 secs) and on clicking this link a window appears asking if i want to close the window...on pressing yes the entire page closes...even my home page!:((

What should be done so that only the small window closes and not my home page?

9:36 am on Nov 18, 2004 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Try the following:

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

:)

2:31 pm on Nov 18, 2004 (gmt 0)

10+ Year Member



What should be done so that only the small window closes and not my home page?

Did you put the link in the small window, or in the home page itself? It needs to be in the small window.

2:40 pm on Nov 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[pre]
<input type="button"
value="Click Here for instructions in closing this window"
onclick="alert('Closing this window:\nClick the small black X at the top corner of the window')" />
[/pre]
2:46 pm on Nov 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or: <a href="#" onClick="window.close()">close</a>
9:26 am on Nov 21, 2004 (gmt 0)

10+ Year Member



I am putting the codes in the small window.but the main web page is closing ...what is happening!
6:08 pm on Nov 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



have you tried these codes in other browsers? maybe the problem lies there.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month