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()
 
 }
原文地址:https://www.cnblogs.com/leejersey/p/3916562.html