首页 > 代码库 > ajax hash缓存

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()  }