JS阻止浏览器返回代码
一段可以阻止浏览器返回的代码,今天无意打开了一个网站,发现怎么也返回不了,仔细研究了一下网站代码找到了无法返回的原因,于是将这段代码提取出来了。
仅供大家学习交流,请勿使用在自己的网站上,这算是一种比较流氓的行为。
<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> 相关文章
- JS判断手机端跳转代码
JS判断手机端跳转代码 复制代码 代码如下: var browser={ versions:function(){ var u = navigator.userAgent, app = navigator.appVersion; return {//移动终端浏览器版本信息 trident: u.indexOf(Trident) -1, //IE内核 Opera: u.indexOf(Opera) -1, //ope
- 从腾讯网提取的判断手机端访问跳转代码
从腾讯网提取的判断手机端访问跳转代码,使用了一个正则表达式来判断浏览器的navigator.userAgent标志,来确认访问终端,从而做出相应的操作。 代码简单,注释详细,容易理解。 复制代码 代码如下: script type=text/javascript if(/Android|Windows Phone|w
- JS判断手机访问函数
函数is_mobile()手机端返回true,PC端返回false,根据返回值来判断时候是手机端访问,然后做相应的操作。 复制代码 代码如下: script function is_mobile() { var regex_match = /(nokia|iphone|android|motorola|^mot-|softbank|foma|docomo|kddi|up.browse
- 标题滚动效果演示
纯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
- JS cookie操作函数
JS cookie操作函数,Cookie增加,读取,删除。 复制代码 代码如下: //获得coolie 的值 function cookie(name) { //得到分割的cookie名值对 var cookieArray = document.cookie.split(; ); var cookie = new Object(); for (var i = 0; i cookieArray.length;
随机推荐
- JS判断手机端跳转代码
JS判断手机端跳转代码 复制代码 代码如下: var browser={ versions:function(){ var u = navigator.userAgent, app = navigator.appVersion; return {//移动终端浏览器版本信息 trident: u.indexOf(Trident) -1, //IE内核 Opera: u.indexOf(Opera) -1, //ope
- 从腾讯网提取的判断手机端访问跳转代码
从腾讯网提取的判断手机端访问跳转代码,使用了一个正则表达式来判断浏览器的navigator.userAgent标志,来确认访问终端,从而做出相应的操作。 代码简单,注释详细,容易理解。 复制代码 代码如下: script type=text/javascript if(/Android|Windows Phone|w
- JS判断手机访问函数
函数is_mobile()手机端返回true,PC端返回false,根据返回值来判断时候是手机端访问,然后做相应的操作。 复制代码 代码如下: script function is_mobile() { var regex_match = /(nokia|iphone|android|motorola|^mot-|softbank|foma|docomo|kddi|up.browse
- 标题滚动效果演示
纯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
- JS cookie操作函数
JS cookie操作函数,Cookie增加,读取,删除。 复制代码 代码如下: //获得coolie 的值 function cookie(name) { //得到分割的cookie名值对 var cookieArray = document.cookie.split(; ); var cookie = new Object(); for (var i = 0; i cookieArray.length;