Freelance Forums

Full Version: A message box when page opens
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Code:
<!-- this script got from www.javascriptfreecode.com coded by: Krishna Eydatoula-->
<html>
<head>
<script language="javascript" type="text/javascript">
alert("Welcome to my site")
</script>
</head>
</html>      
<font face="Tahoma"><a target="_blank" href="http://www.javascriptfreecode.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>


Make sure to edit this...[/code]

Very cool, but I like this code better because it will display the alert when the page completely loads.

Code:
<body onload="javascript:alert('Welcome to my site!');"/>

Or you could always have the alert displayed when a button is clicked. Wink

Code:
<html>
<head>
<script type="text/javascript">
function disp_alert()
{
alert("Text here")
}
</script>
</head>
<body>

<input type="button" onclick="disp_alert()" value="Alert Box button," />

</body>
</html>

I personally hate alerts... I think they get visitors upset.
Reference URL's