ajax hash缓存

hash 模拟url路由

function hashdone(){
       var hash;
       hash=(!window.location.hash)?"#one":window.location.hash;
       window.location.hash=hash;
       var hashStr = location.hash.replace("#","");
       switch(hash){
           case "#one":
               alert(hashStr)
 
               break;
           case "#second":
               alert(hashStr)
 
               break;
           case "#third":
               alert(hashStr)
 
               break;
 
 
       }
   }
   hashdone()
 window.onhashchange=function(){
    hashdone()
 
 }

 

posted @ 2014-08-16 16:50  leejersey  阅读(787)  评论(0编辑  收藏  举报