监听地址栏hash值的变化

2018-01-27 12:43:28

1  history.js//兼容ie6+

2  hashchange

$(window).on("hashchange", function() {//兼容ie8+和手机端
            $('.div1').append(This.location.hash);
        });

3 pushState//兼容ie9+

http://www.zhangxinxu.com/wordpress/2013/06/html5-history-api-pushstate-replacestate-ajax/

http://www.cnblogs.com/hustskyking/p/history-api-in-html5.html

$('.a').on('click', function() {// 创建新history实体
             history.pushState({a:'aa'}, '', location.href+'?'+Math.random());
             });
             $('.b').on('click', function() {// 修改新history实体(虽然浏览记录确实生成了2条,但是实际你只能找到被修改后的{a:'bb'})
             history.replaceState({a:'bb'}, '', location.href+'?'+Math.random()+'------');
             });
             window.addEventListener('popstate', function() {// 前进后退触发
                console.log(history);
                console.log(history.state);// 这里是你设置的{a:'aa'}
             });


  • 2018-01-18 11:26:53

    浅谈js运行机制(线程)

    从开始接触js时,我们便知道js是单线程的。单线程,异步,同步,互调,阻塞等。在实际写js的时候,我们都会用到ajax,不管是原生的实现,还是借助jQuery等工具库实现,我们都知道,ajax可以实现局部刷新,并且在请求处理时,任然可以响应用户的操作,比如点击事件。不是说js是单线程吗?这些都是怎么实现的? 在阅读《深入理解Bootrap的源码》一书,在分析轮播组件(carousel.js)的源码时,作者对一句代码操作的注释引起了我的兴趣。

  • 2018-01-18 17:41:05

    Fatal error: Class 'Memcached' not found

    从别地方复制来了新的配置文件,包了这样的错误,因为我也是刚刚安装了php7,以为是php的问题,于是就根据网上的提示,安装memcached.dll包。

  • 2018-01-20 20:33:58

    PHP中session_cache_limiter() 是什么意思啊

    session_cache_limiter('public'); session_cache_expire(30); session_start();第三个我晓得 前两个 网络上没找着资料 手册上全是英文的 翻译后 还是看不懂主要是没翻译正确