如何在当前页面上匹配整个JavaScript函数?我的JavaScript功能是:
window.onbeforeunload = function()
{
if( !success )
{
success = true;
alert('Think first! Click CANCEL on the next page to receive a new gift.\n\n');
window.location = 'http://www.mysite.com/';
return '\nClick CANCEL\n\nOver thousands of gifts have been given out, get yours today!\n\n';
}
}
我希望动态匹配并将此函数替换为:
window.onbeforeunload=function()
{
return ExitPopup();
}
请帮我解决这个问题。
答案 0 :(得分:1)
var newFunction = function()
{
return ExitPopup();
}
然后
window.onbeforeunload = newFunction;