当前位置:网站首页>离开页面的提示
离开页面的提示
2022-07-26 22:49:00 【识时务者-HJJ】
离开页面的提示
在记录文章和问答时,总是因为不小心关闭页面标签而导致数据丢失,辛辛苦苦写的文章全部丢失,心累~
在文章问答页加上js代码
<!--询问是否离开页面-->
<script>
window.onbeforeunload = function (event) {
event.preventDefault();
}
</script>

在关闭标签时会询问是否离开,防止误点关闭标签导致数据丢失。
界面提示文本
Firefox "此页面想询问您是否要离开 - 您输入的数据可能不会被保存"
Safari "您确定要离开此页面吗?"
Chrome "重新加载此网站?”“系统可能不会保存您所做的更改。"
不同的浏览器会有不同的界面提示文本,确保写文章问答时数据不丢失,非常的nice~
window.onbeforeunload无效
在Chrome和Firefox中,页面加载完成后,如果用户未对页面进行操作,比如“点击”、“输入”等等,onbeforeunload将不会被执行。
而在Safari中onbeforeunload总是会被执行。
需要指出的是,许多浏览器会忽略该事件并自动关闭页面无需用户的确认。
我的学习论坛
HandsomeForum:用Java编写的学习论坛,打造我们自己的圈子!(http://huangjunjie.vip:66)
文章链接:http://huangjunjie.vip:66/question/read/582q3u645tzq7q73yq
边栏推荐
猜你喜欢

2022 latest Tiktok live broadcast monitoring (II) streaming media download in live broadcast room

C语言——二维数组、指针

全网显示 IP 归属地,是怎么实现的?

OSPF在MGRE环境下配置及LSA的优化---减少LSA更新量(汇总、特殊区域)

First knowledge of C language (2)

ensp中的简单静态路由
![[explain C language in detail] takes you to play with the choice (Branch) structure](/img/ca/7ee9f62a2478785c97684c7a0cc749.png)
[explain C language in detail] takes you to play with the choice (Branch) structure

TCP的三次握手与四次挥手(简述)

Gan's training skills: alchemist cultivation plan - generative confrontation network training, participation and improvement

HCIA基础知识(1)
随机推荐
OSPF configuration in mGRE environment and LSA optimization - reduce the amount of LSA updates (summary, special areas)
Timer interrupt experiment
C语言——字符和字符串、算术运算符、类型转换
第三讲--GPIO输入输出库函数使用以及相关例程
FID index reproduction step on the pit to avoid the pit text generation image FID quantitative experiment whole process reproduction (FR é Chet inception distance) quantitative evaluation experiment s
Experiment of OSPF in mGRE environment
First knowledge of C language (2)
Golang bufio Reader 源码详解
[Database Course Design] SQLSERVER database course design (student dormitory management), course design report + source code + database diagram
Static comprehensive experiment (comprehensive exercise of static route, loopback interface, default route, empty interface, floating static)
C language implementation of the small game [sanziqi] Notes detailed logic clear, come and have a look!!
Codeforces Round #807 (Div. 2), problem: (C) Mark and His Unfinished Essay
[volatile principle] volatile principle
mgre的全连和星型拓扑实验
(the most detailed in History) codeforces round 805 (Div. 3) e Split Into Two Sets
Lecture 4 - explain GPIO_ Write function and related routines
First knowledge of Web Design
TCP's three handshakes and four waves (brief introduction)
数字集成电路:CMOS反相器(一)静态特性
[explain C language in detail] takes you to play with the choice (Branch) structure