How to disable “prevent this page from creating additional dialogs”?

前端 未结 6 1543
一个人的身影
一个人的身影 2020-12-02 20:28

I\'m developing a web app that utilises JavaScript alert() and confirm() dialogue boxes.

How can I stop Chrome from showing this checkbox?<

6条回答
  •  暖寄归人
    2020-12-02 21:18

    This is what I ended up doing, since we have a web app that has multiple users that are not under our control...(@DannyBeckett I know this isn't an exact answer to your question, but the people that are looking at your question might be helped by this.) You can at least detect if they are not seeing the dialogs. There are few things you most likely want to change like the time to display, or what you are actually displaying. Remember this will only notify the user that they are have managed to click that little checkbox.

    window.nativeAlert = window.alert;
    window.alert = function (message) {
        var timeBefore = new Date();
        var confirmBool = nativeAlert(message);
        var timeAfter = new Date();
        if ((timeAfter - timeBefore) < 350) {
            MySpecialDialog("You have alerts turned off");
        }
    }
    
    window.nativeConfirm = window.confirm;
    window.confirm = function (message) {
        var timeBefore = new Date();
        var confirmBool = nativeConfirm(message);
        var timeAfter = new Date();
        if ((timeAfter - timeBefore) < 350) {
            MySpecialDialog("You have confirms turned off");
        }
        return confirmBool;
    }
    

    Obviously I have set the time to 3.5 milliseconds. But after some testing we were only able to click or close the dialogs in about 5 milliseconds plus.

提交回复
热议问题