Javascript Alert

Alert boxes are used to provide the user with important information. When users enter your site and you want to make sure that they sign your guestbook, you can use an alert box to remind them. Keep in mind, that overusing this function can get very annoying and your visitors might decide not to come back.

Alert Box Example:

<html>
<head>
<title>Alert Boxes</title>
<script>
<!-- Hide Script
	alert("My Own JavaScript Alert Box!")
//End Hide Script-->
</script>
</head>
<body>
<noscript>
  This page uses JavaScript.
  Please enable it or upgrade your browser.
</noscript>
</body>
</html>

alert(“My Own JavaScript Alert Box!”), that’s the code for your alert box. Put any text inside the quotation marks in alert() and it will pop up next time you load the page.

The JavaScript alert box will always say “JavaScript Application” and there’s no way to code around it. We suppose it’s a security feature so that a site owner can’t trick visitors into something using an alert box.

You might have seen that we used the <noscript> tag above. That’s because in non-JavaScript browsers (JavaScript turned off or not supported) a message will show up saying “This page uses JavaScript. Please enable it or upgrade your browser.”.

Did you like this post? Get monthly summary of our new tutorials, posts and tips to your inbox!

No Responses

Post Your Comment

Your email address will not be published.