国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

javascript - How to close the already opened alert dialog box with jq or js
天蓬老師
天蓬老師 2017-05-19 10:24:57
0
3
980

How to close the open alert dialog box in jq or js

I have opened an alert through a callback function, and now I want it to be displayed for a few seconds and then automatically close. How can I do it with jq? js is also possible. If the function is hijacked, it will target all alerts on the current page. I am currently You only need to control one of the alerts, and I beg the front-end master for answers

ps: This is not the point of the question. I am afraid that someone will ask me why I did this...
In addition, I am using this for H5 web Notification. I open the reduced page through Notification's click callback. I don't know how. Writing, I had to use alert to re-maximize the page

var msg = 'test';
var n = new Notification("來(lái)自用戶xxxx的新消息", {  
    icon: 'pic.png',  
    body: '消息內(nèi)容:'+msg  
});  
n.onclick = function() {
    alert(1234);
    //想通過(guò)劫持函數(shù)來(lái)重新定義alert函數(shù)……但是好像是全局的……
    var ALERT_ON = true; 
    var _alert = window.alert;
    window.alert = function(msg) {
        if (ALERT_ON) {
            _alert(msg);
        }
    }
    //location.reload();
    n.close();
};
天蓬老師
天蓬老師

歡迎選擇我的課程,讓我們一起見(jiàn)證您的進(jìn)步~~

reply all(3)
某草草

Alert pop-up window seems to have no way to close automatically.
You can write an alert pop-up window yourself.


I will re-edit it to get the effect the up owner wants.
Click the Notification notification to zoom in or display the current page.

Just add this line of code to the onclick of Notification.

window.focus();
洪濤

alert will interrupt the execution of JS, so this requirement cannot be realized.

過(guò)去多啦不再A夢(mèng)

Because alert cannot be turned off, it can only be disabled, so it is recommended to write a pop-up box by yourself.
Use p to write a masked pop-up modal box, and then setTimeout to close it regularly.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template