JS阻止浏览器返回代码

模板网 2018-07-21

一段可以阻止浏览器返回的代码,今天无意打开了一个网站,发现怎么也返回不了,仔细研究了一下网站代码找到了无法返回的原因,于是将这段代码提取出来了。

仅供大家学习交流,请勿使用在自己的网站上,这算是一种比较流氓的行为。

<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
!(function() {
	if (window.history && window.history.pushState) {
		$(window).on('popstate', function() {
			window.history.pushState('forward', null, document.URL);
			window.history.forward(1);
		});
	}
	window.history.pushState('forward', null, document.URL);
	window.history.forward(1);
})();
</script>

相关文章

  1. JS邮箱验证函数

    JS邮箱验证函数。 关键代码: 复制代码 代码如下: function emailCheck(str){ return /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test(str); } 使用方法: emailCheck(邮箱); alert(emailCheck(10001

  2. HTML图片热区map area谷歌浏览器Google去除边框

    HTML图片热区map area去除边框默认的情况下 在Google浏览器中打开的时候周围会有蓝色的边框。 在area中加入以下代码可以去除边框: hidefocus=true onfocus=this.blur(); 完整代码如下: 复制代码 代码如下: img src=http://www.120muban.com/statics/images/l

  3. JS闪屏代码,闪瞎你的眼睛

    JS恶搞代码,页面底色在黑与白之间快速切换,产生闪烁效果。JS闪屏代码,闪瞎你的眼睛。

  4. jquery实现的tab切换

    1、jQuery能够使用户的html页保持代码和html内容分离,也就是说,不用再在html里面插入一堆js来调用命令了,只需定义id即可。下面跟大家分享一个jquery的tab切换 2、如何使用 调用jquery文件 script type=text/javascript src=jquery.js/script jquery实现ta

  5. 标题滚动效果演示

    纯JS实现的标题滚动效果。代码如下: 复制代码 代码如下: script type=text/javascript (function(){ setInterval(function(){ text = top.document.title; top.document.title=text.substring(1,text.length)+text.substring(0,1); },500); })(); /script

随机推荐

  1. JS邮箱验证函数

    JS邮箱验证函数。 关键代码: 复制代码 代码如下: function emailCheck(str){ return /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test(str); } 使用方法: emailCheck(邮箱); alert(emailCheck(10001

  2. HTML图片热区map area谷歌浏览器Google去除边框

    HTML图片热区map area去除边框默认的情况下 在Google浏览器中打开的时候周围会有蓝色的边框。 在area中加入以下代码可以去除边框: hidefocus=true onfocus=this.blur(); 完整代码如下: 复制代码 代码如下: img src=http://www.120muban.com/statics/images/l

  3. JS闪屏代码,闪瞎你的眼睛

    JS恶搞代码,页面底色在黑与白之间快速切换,产生闪烁效果。JS闪屏代码,闪瞎你的眼睛。

  4. jquery实现的tab切换

    1、jQuery能够使用户的html页保持代码和html内容分离,也就是说,不用再在html里面插入一堆js来调用命令了,只需定义id即可。下面跟大家分享一个jquery的tab切换 2、如何使用 调用jquery文件 script type=text/javascript src=jquery.js/script jquery实现ta

  5. 标题滚动效果演示

    纯JS实现的标题滚动效果。代码如下: 复制代码 代码如下: script type=text/javascript (function(){ setInterval(function(){ text = top.document.title; top.document.title=text.substring(1,text.length)+text.substring(0,1); },500); })(); /script