Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

html or javascript for doing this function? 2

Status
Not open for further replies.

lullysing

ISP
Sep 29, 2003
204
US
Hi.

I am modifying a website for a friend, and he has asked me something which i am not sure how to do, either using HTML or javascript.

Essentially, what he wants is that in the event of someone closing the browser window from his site, for a very small popup to appear and saying goodbye, and to visit soon ( since the place ain't finished building yet).

I'll be honnest, i'm mostly a OS guy, i don't really do coding or designing webpages, but i owe the guy a favor. Would you people know where i can get understandable code to put into my existing page, or where i can get a tutorial into making that kind of simple function for my friend's site? I think this can mostly be done with javascript, but if it can be done using html, let me know too?

Thank you.
Dave.
 

HTML doesn't have functionlity to the point of reaction on user events. javascript and or IE only vbscript will need to enter into as you thought.
just combine those two functions. Although I know onUnLoad is (was) not all that browser friendly. that was a version or two ago though

_____________________________________________________________________
Where have all my friends gone to????
onpnt2.gif

 
so if i get this right ( remember, i don't usually code anything of the sort ) the body tag would look like something like this :

<BODY onUnload=&quot;window.alert(&quot;Thank you for visiting the site /n and visit in a few days when the site's gonna be finished&quot;)&quot; >

And you say this works only on IE? so it can't be tested from my linux station?

--Dave
 
Paste this into a new .html file and have a poke around:
Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd&quot;>[/URL]
<html>
<head>
<title>test bed</title>
<script language=&quot;JavaScript&quot;>
function showAlert()
{
    alert(&quot;You can now OK this annoying box&quot;);
}
</script>
</head>
<body onunload=&quot;showAlert();&quot;>
<p>Try these:<br>
1. Close this page<br>
2. Leave via hyperlink like <a href=&quot;[URL unfurl="true"]http://www.useit.com/alertbox/&quot;>this[/URL] link</a> (or manually typing a link into the address bar)<br>
3. Refresh this page<br>
They all trigger the onunload event in IE6 and NN7 except number 1. in NN7.
</p>
</form>
</body>
</html>

Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
clarkin .... I must say that is the most ingenious signature i have ever seen!


&quot;Why is it always the quiet ones?&quot;

Robert Carpenter
questions? comments? thanks? email me!
linkemapx@hotmail.com
AIM & MSN: robacarp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top