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");
};
alert
itself - it's simply not possible. It just binds the name "alert" to a new function. – Corrody