检测浏览器后退按钮 [英] Detect browser back button

查看:93
本文介绍了检测浏览器后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以检测到在JavaScript中单击的浏览器后退按钮吗?
我在页面中使用onbeforeunload()函数.
但是此函数每次都会调用-单击后退按钮,刷新时

我们可以检查是否单击了后退按钮吗?

Can we detect browser back button clicked in javascript?
I am using onbeforeunload() function in my page.
But this function calls everytime- on back button click, on refresh

Can we check that back button is clicked?

推荐答案

每天至少询问一次.答案总是一样的.您无法可靠地检测到它,并且如果您尝试阻止它的发生,那么您的黑客很容易会被想要成为它的人破解.最好的办法是正确编写您的网站,以便后退按钮不会执行您不希望做的任何事情.
This is asked at least once a day. The answer is always the same. you can''t reliably detect it, and if you try to stop it from happening, your hack can easily be broken by someone who wants it to be. The best thing is to write your site properly so the back button doesn''t do anything you don''t want it to.


这篇关于检测浏览器后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆