Monday, April 23, 2012

Is there a way to clone native functions in javascript like window.alert or document.write

What I want to do is change every alert in the code to a custom alert("you used alert");



var hardCodedAlert = alert; //I know this won't work.But what to do ?
window.alert=function(){
if(this.count == undefined)
this.count=0;
this.count=this.count+1;
if(this.count == 1)
hardCodedAlert("You used alert");
};




No comments:

Post a Comment