草庐IT

alertMesg

全部标签

javascript - 如何动态更改 JavaScript 函数的一行?

假设我有以下功能:functionalertMesg(){alert("Thisokfunctionalertsmessage!");}现在,在运行时,我想更改alertMesg函数来执行其他操作。我的想法是做这样的事情。vartemp=window.alertMesg.toString.replace("ok","great")temp=temp.replace('functionalertMesg()',"");window.alertMesg=newFunction(temp);基本上,问题是我无法控制alertMesg函数中的源。我想更改功能,但实际上我无法更改它的来源,因为它