简体   繁体   English

如何正确修改JavaScript中的警报功能

[英]How to properly modify the alert function in javascript

I want to check the contents of the alert before it "alerts". 我想在“警报”之前检查警报的内容。

I have this function: 我有这个功能:

function alert(msg) {

    // THIS WILL CHECK IF THE WORD FUNCTION IS EXISTING IN A STRING
    var searchFunction = jQuery.type(msg);

    if(searchFunction != 'function')
    {
        return;
    }
}

However, I don't know how to "alert" since I modified the alert function already. 但是,由于已经修改了警报功能,因此我不知道如何“警报”。

Thanks in advance! 提前致谢!

However, I don't know how to "alert" since I modified the alert function already. 但是,由于已经修改了警报功能,因此我不知道如何“警报”。

Before modifying the alert, do this: 在修改警报之前,请执行以下操作:

var myAlert = alert;

Now you can do myAlert("Hi, I am a alert"); 现在您可以执行myAlert("Hi, I am a alert");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM