匹配和替换完整的javascript函数



如何在当前页面上匹配整个JavaScript函数?我的JavaScript函数是:

window.onbeforeunload = function()
{
    if( !success )
    {
        success = true;
        alert('Think first! Click CANCEL on the next page to receive a new gift.nn');
        window.location = 'http://www.mysite.com/';
        return 'nClick CANCELnnOver thousands of gifts have been given out, get yours today!nn';
    }
}

和我想动态匹配并替换这个函数为:

window.onbeforeunload=function()
{
    return ExitPopup();
}

请帮我解决这个问题

你就不能这么做吗

var newFunction = function()
{
    return ExitPopup();
}

window.onbeforeunload = newFunction;

相关内容

  • 没有找到相关文章

最新更新