Javascript Alert:Tips, Customized Alert Box

The JavaScript language itself provides very few debugging tools. One of the few that it does provide and perhaps the most useful is alert(). The alert command allows you to pop up a message in your browser.

Customized Alert Box

Custom Alert-box
Custom Alert-box

You can implement an Custom Alert Boxes. Source files are attached.

Download the Source File

(Zip extracting password:configpixel)

1) Alert Message With JavaScript

1
2
3
<script type="text/javascript"> 
alert(“Your message here”); 
</script>

2) Alert Message Box With Confirmation

1
2
3
4
5
6
7
8
9
<script type="text/javascript"> 
confirm('Go for search?'); 
if (confirm('Go for search?')) { 
window.location = " http://www.google.com/"; 
} 
else { 
window.location = "</strong> <strong>http://www.wikipedia.org/"; 
} 
</script>

3) Display Variable Values in the Alert

1
var vname = "alert"; alert('The variable name is ' + vname);

4) Alert Message with Multiple Line

1
alert( "First Name   = Config" + '\n' + "Second Name = Pixel" + '\n' + "Category = Web based blog" );

5) Good Bye Alert

With the use of this JavaScript you can display an alert when the user clicks on any link that will cause him or her to exit your website.

1
<body onUnload="window.alert('YOUR MESSAE GOES HERE')">

 

6) Image Rollover Alert

1
2
3
<a onmouseover="alert('YOUR MESSAGE'); return true;">
<img src="YOUR IMAGE FILE" alt="" border="0" />
</a>

 

7)  Alert On Page Open Insert into <HEAD>

1
2
3
<script type="text/javascript" language="JavaScript">// <![CDATA[
 alert('Welcome to my Web Site!');
// ]]></script>

 


8 ) Make Alert from FLASH

1
2
3
4
5
function AlertWindow(event:MouseEvent):void{
var alert:URLRequest = new URLRequest("javascript:alert('Hello Alert')");
navigateToURL(alert,"_self");
}
AlertBtn.addEventListener(MouseEvent.CLICK,AlertWindow);

 


 

var vname = “alert”;

alert(‘The variable name is ‘ + vname);