View Full Version : Custom Alert Box

01-07-2007, 12:29 PM
You can create a custom alert box using div, layer and tables.
first you create a HTML view similar to an alert box by using any of dov,layers and tables. make the visibility property to hidden when loading.
using javascript make it visible at which ever position you want... and then one more thing... when a default alert box appears we will be able to do any other event on that page... i hope you get my idea... like that you can do when you show your custom alert box by disabling the mouse and keyboard events like the following...

i have tested this code in Internet explorer



var ef=0

function showalert()

var ids

function disableEvents()
return false;


<div align=center id="alert" style="position:absolute;left:0;top:0;border: 2px solid gray; width:100; height:100;color:red; background-color:black;visibility:hidden;">

<br>Alert Message <br><br><br>

<input type=button name=ok value=0k onclick="ef=0;document.getElementById('alert').style.visibility='hidden';" >


consider there is some error you want show when this link is clicked
<a href="javascript: showalert();">click here</a>


note: you may wonder how the ok button is working after disabling the onclick event for the whold document... it is because i think the first priority goes to the ok buttons onclick event only after that documents onclick event is checked...

request: if any one else knows a better solution for the above note please put that to my email jayapalchandran@gmail.com