当前位置:首页 > 技术记录 > 正文内容

如何判断页面是通过返回按钮进入

ogfogf5年前 (2021-03-30)技术记录2033

window.addEventListener('pageshow', function (event) {

        if(event.persisted || window.performance && window.performance.navigation.type == 2){

            console.log('window.performance.navigation.type: '+ window.performance.navigation.type);

            alert("监听到是点击返回按钮进入本页的了")

            // location.refresh();   //此处可以写你的实际应用的代码

        }

    },false);



扫描二维码推送至手机访问。

版权声明:本文由技术建站文档发布,如需转载请注明出处。

分享给朋友:

相关文章

安装飞桨https://www.paddlepaddle.org.cn/

是在python3.8下成功的yum install python38python3.8 -m pip install paddlepaddle==2.3.2 -i https://pypi.tuna...

Linux 查找某一时间段文件

Linux 查找某一时间段文件find ./ -name "*.*" -newermt "2020-12-07 10:00" ! -newermt "...

python 通过 无头下载

https://blog.csdn.net/hollycloud/article/details/126745964 https://googlechromelabs.github.io/chrome...

Linux关闭防火墙命令

一、下面是red hat/CentOs7关闭防火墙的命令!1:查看防火状态systemctl status firewalldservice iptables status2:暂时关闭防火墙syste...

豆荚直播助手 直播加加可以绿幕

豆荚直播助手 直播加加可以绿幕,直播利器...

JS使用H5实现图片预览

JS使用H5实现图片预览

<!DOCTYPE html><html><head><meta charset="UTF-8"><title>文件上传...