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. 网站新信息标题闪烁效果实现

    网站新信息标题闪烁效果实现,很简单的一个功能,但是非常的实用,能够吸引访客注意,有效提高转化。 效果图:

  2. 标题滚动效果演示

    纯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

  3. 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

  4. 使用新浪获取IP所在地接口做网站跳转

    使用新浪获取IP接口做网站跳转 title使用新浪获取IP接口做网站跳转/title !--引用新浪IP获取接口-- script type=text/javascript src=http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js/script !--引用新浪IP获取接口-- script type=text/javas

  5. JS 文本框默认提示信息点击清空

    JS 文本框默认提示信息点击清空,关键的代码。 复制代码 代码如下: onfocus=if(this.value==this.defaultValue){this.value=;}; onblur=if(this.value==){this.value=this.defaultValue;} type=text 效果截图:

随机推荐

  1. 网站新信息标题闪烁效果实现

    网站新信息标题闪烁效果实现,很简单的一个功能,但是非常的实用,能够吸引访客注意,有效提高转化。 效果图:

  2. 标题滚动效果演示

    纯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

  3. 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

  4. 使用新浪获取IP所在地接口做网站跳转

    使用新浪获取IP接口做网站跳转 title使用新浪获取IP接口做网站跳转/title !--引用新浪IP获取接口-- script type=text/javascript src=http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js/script !--引用新浪IP获取接口-- script type=text/javas

  5. JS 文本框默认提示信息点击清空

    JS 文本框默认提示信息点击清空,关键的代码。 复制代码 代码如下: onfocus=if(this.value==this.defaultValue){this.value=;}; onblur=if(this.value==){this.value=this.defaultValue;} type=text 效果截图: