简体   繁体   中英

How to show pop-up then user close page use js

I have broblem.

Situation - user first time visited in site. User want close page (not go anover page, only close). Site have pop up comprising offer discounts.

I need show pop up befor user left site.

Use onbeforeunload method.

window.onbeforeunload = function(){
    return 'Your message here.';
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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