Skip to main content

Posts

Showing posts from May, 2010

A JavaScript Alert as I want

There are alerts and confirms on JS as you all know. But its look and feel is same old style. I was curious whether we can change it. Of cause we are normally using a div tag and apply some styles to the background to gray out. Then we can use it as a function and call it whenever we need an alert. Isn’t there a better way to do that? I mean much easier way. So what I have tried to do was override the alert functionality on JS and give a customized method to do the job. So then what happens is we don’t need to change the code on each and every place where it used alert(“this is message”); . I have found the way to this on http://slayeroffice.com/code/custom_alert/ This place can be changed so I have pasted the JS code also in here. // constants to define the title of the alert and button text. var ALERT_TITLE = "Oops!"; var ALERT_BUTTON_TEXT = "Ok"; // over-ride the alert method only if this a newer browser. // Older browser will see standard alerts if(docume