Confirmation of top.window.close

S

ScooterMX

I have a <a href="javascript:top.window.close()"><img src="exit.gif"></a>
tag on my page that closes itself when you click on it.

What I NEED is for it to put up a confirmation message that simply asks
"This will end your session and close the window", then offers a cancel or
ok button. Clicking on ok closes both the page it was on, and the
confirmation window.

Can someone suggest a simple way to do this?

thanks in advance

Scooter
 
M

McKirahan

ScooterMX said:
I have a <a href="javascript:top.window.close()"><img src="exit.gif"></a>
tag on my page that closes itself when you click on it.

What I NEED is for it to put up a confirmation message that simply asks
"This will end your session and close the window", then offers a cancel or
ok button. Clicking on ok closes both the page it was on, and the
confirmation window.

Can someone suggest a simple way to do this?

thanks in advance

Scooter


Will this work for you? Watch for word-wrap.

<img src="exit.gif" onclick="if(confirm('This will end your session and
close the window')) window.close()">
 
S

ScooterMX

Brilliant, thanks. Removing the href made the pointer stop changing (from
the arrow to the finger) on the mouseover. Is there a way to make it still
act like an href?
 
R

Randy Webb

ScooterMX said:
Brilliant, thanks. Removing the href made the pointer stop changing (from
the arrow to the finger) on the mouseover. Is there a way to make it still
act like an href?

Yes. Make it a link and then it acts like a link. Use the onclick of the
link and return false from it.

Please don't top-post, read the FAQ with regards to such.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 
M

McKirahan

ScooterMX said:
Brilliant, thanks. Removing the href made the pointer stop changing (from
the arrow to the finger) on the mouseover. Is there a way to make it still
act like an href?


cancel

<img src="exit.gif" onclick="if(confirm('This will end your session and
close the window')) window.close()" style="cursor=hand">

Though if it's not IE maybe it's "cursor=pointer".
 
J

Joakim Braun

"McKirahan" <[email protected]> skrev i meddelandet
<img src="exit.gif" onclick="if(confirm('This will end your session and
close the window')) window.close()" style="cursor=hand">

Though if it's not IE maybe it's "cursor=pointer".

style="cursor:pointer"

Joakim Braun
 
S

ScooterMX

Is there a way to constrain the size of the confirm methods 'window'? The
text I want to use is rather long, and I want it to wrap rather than
stretching the message window across the entire screen.
 
M

McKirahan

ScooterMX said:
Is there a way to constrain the size of the confirm methods 'window'? The
text I want to use is rather long, and I want it to wrap rather than
stretching the message window across the entire screen.

Use "\n" for a line break:

<img src="exit.gif" onclick="if(confirm('This \nwill \nend \nyour \nession
\nand \nclose \nthe \nwindow')) window.close()" style="cursor=hand">
 
S

ScooterMX

Is there a way to constrain the size of the confirm methods 'window'?
The
Use "\n" for a line break:

<img src="exit.gif" onclick="if(confirm('This \nwill \nend \nyour \nession
\nand \nclose \nthe \nwindow')) window.close()" style="cursor=hand">

perfect, thanks.
 
D

DU

ScooterMX said:
Brilliant, thanks. Removing the href made the pointer stop changing (from
the arrow to the finger) on the mouseover. Is there a way to make it still
act like an href?

First, avoid top-posting. Top-posting destroys chronological order of
posts in threads and makes reading more difficult.

Second, use a button, not a link. A link should always act like a link,
fetching a referenced resource on the web. A link should always work
even with javascript support disabled.
If you want to add an image into that button, then you still can.

Third, you would be a lot better with using the onbeforeunload event
attached to the window object: onbeforeunload is supported by MSIE 5+,
Firefox, NS 7.2 and Mozilla releases.

DU
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top