当前位置:网站首页>Prompt to leave the page
Prompt to leave the page
2022-07-27 02:25:00 【Current affairs reader hjj】
List of articles
Tips for leaving the page
When recording articles and questions and answers , Data loss is always caused by accidentally closing the page tag , All the articles written hard are lost , Heart tired ~
Add js Code
<!-- Ask if you want to leave the page -->
<script>
window.onbeforeunload = function (event) {
event.preventDefault();
}
</script>

When closing the tag, you will be asked whether to leave , Prevent data loss caused by late closing of labels .
Interface prompt text
Firefox " This page wants to ask if you want to leave - The data you enter may not be saved "
Safari " Are you sure you want to leave this page ?"
Chrome " Reload this site ?”“ The system may not save your changes ."
Different browsers will have different interface prompt text , Make sure you don't lose data when writing questions and answers , very nice~
window.onbeforeunload Invalid
stay Chrome and Firefox in , After the page loads , If the user does not operate on the page , such as “ Click on ”、“ Input ” wait ,onbeforeunload Will not be carried out .
And in the Safari in onbeforeunload It will always be executed .
It's important to point out that , Many browsers will ignore this event and automatically close the page without user confirmation .
My learning forum
HandsomeForum: use Java Prepared Learning Forum , Build our own circle !(http://huangjunjie.vip:66)
The article links :http://huangjunjie.vip:66/question/read/582q3u645tzq7q73yq
边栏推荐
猜你喜欢

(prefix and / thinking) codeforces round 806 (Div. 4) F Yet Another Problem About Pairs Satisfying an Inequality

静态路由基本配置 实现全网可达

Hcip bidirectional republication and routing strategy

多线程中 synchronized 锁升级的原理是什么?

【C语言】strlen与sizeof相关区分

Codeforces Round #796 (Div. 2), problem: (1688C) Manipulating History

Hcip day 1

C language - first program, print, variables and constants

C language -- nesting of relational and logical operators, if statements, switch statements, and branch structures

求解100~200之间的素数
随机推荐
CF 1333C Eugene and an array
OSPF configuration in mGRE environment and LSA optimization - reduce the amount of LSA updates (summary, special areas)
(super detailed version, don't know to comment at any time) codeforces round 804 (Div. 2) C the third problem
记录HandsomeBlog的star用户
数字集成电路:MOS管器件章(一)
Lesson 5 - key control LED
HCIP第一天静态路由综合实验
Golang中的错误处理
光光光仔的CSDN之旅
HCIP oSPF综合实验
OSPF protocol knowledge summary
Codeforces Round #810 (Div. 2), problem: (B) Party
求解整数的每一位
今天浅讲一下转义字符【萌新版】
有趣的C语言
Error handling in golang
【洋哥带你玩转线性表(一)——顺序表】
Solve prime numbers between 100 and 200
Codeforces Round #807 (Div. 2), problem: (C) Mark and His Unfinished Essay
Hcip OSPF knowledge summary