Menu

Downloads

Links



Alerts & Popups



How do I add javascript alerts?

Javascript alerts and confirms can be fun to play with, and add to your site, but you have to keep in mind the main rule when designing a website. You're designing based on the needs of your visitor. Your visitors may not want to be harrassed by a ton of alerts, so be careful not to get carried away. That being said, on to the alerts.

Alert on Click
To have an alert appear when a link is clicked, like the example below, use the following code.



<form ACTION=URI><input type="button" value="Click here!" onClick='alert("See? This alert shows up when someone clicks the button link!")'></form>


Alert on Click with Style
To have an alert appear when a link is clicked, and add some color to the button link, like the example below, use the following code.



<form ACTION=URI><input type="button" style="background:#849AA4" value="Click here!" onClick='alert("See? This alert shows up when someone clicks the button link!")'></form>


Alert on Page Enter
To have an alert appear when someone enters your page, use this code.

<SCRIPT language="JavaScript type="text/javascript"">alert("MESSAGE HERE")</SCRIPT>


Alert on Page Exit
To have an alert appear when someone enters your page, use this code.

<body onunload="alert('MESSAGE HERE');">


Alert on Page Enter & Exit
To have an alert appear when someone enters your page, use this code.

<body onload="alert('ENTER MESSAGE HERE');" onunload="alert('EXIT MESSAGE HERE');">


Multiple Alerts on Page Enter
To have an alert appear when someone enters your page, use this code.

<script language="JavaScript type="text/javascript""> <!-- start script alert("MESSAGE HERE"); alert("MESSAGE HERE"); alert("MESSAGE HERE"); // end script --> </script>


Alert on Hover
To have an alert appear when someone hovers over a link, like the example below, use this code.

Put your mouse over this link!

<a href=""onMouseover="alert('Personally this code drives me nuts.')">Put your mouse over this link!</a>


Javascript Confirm
With this code, when someone enters your site, they will see a popup asking if they're sure they want to continue. If they choose no, they will be taken to another site, one that you've specified in the code.

<script language="javascript" type="text/javascript">
var stay=confirm("Are you sure you want to continue?")
if (!stay)
window.location="http://www.jadedneo.com"
</script>