Hi all,
Suppose I had the following function:
function alertMesg()
{
alert("This ok function alerts message!");
}
Now at run time I would like to change the alertMesg function to do something else. My thought was to do somehting like this.
var temp = window.alertMesg.toString.replace("ok","great")
temp = temp.replace('function alertMesg()',"");
window.alertMesg = new Function(temp);
Basically, the problem is I have no control over the source in the alertMesg function. I would like change the function, but I can't actually change the source of it. Because it is produced server side. That being said I need it to act differently.
Thanks, Grae
PS: I forgot to mention an important part. I have to keep most of the function. I can't just replace the function out right. I have to keep 95% of the function the way it is, and change the other five percent.
@Barlow Tucker, quixoto, pekka Thanks, for the interest.
Basically, I don't think the proxy idea will work because I am not just adding functionallity, I am changing the functionallity of the code. I want for example, the third line of the function to be different. In my real life example I have to add a line right in the middle of a function.