如题, 怎么样用js先刷新页面,然后定位到锚
window.location = window.location.pathname + '#comment';
window.location.reload(); 
现在这样做的,不过只有firefox下好使,其他都不灵呢,js高手来帮忙

解决方案 »

  1.   

    csdn落寞了,技术问题都没人解决了?
      

  2.   

    直接用window.location=window.location.href + "#comment";就可以了。
      

  3.   

    楼上的是种办法。。不过多次以后就会变成xxx.html#comment#comment#comment#comment....这样了。。
      

  4.   

    <script type="text/javascript">
    function goAnchor(anchorStr){
    var hash=window.location.hash;
    var href=window.location.href;
    return href.substr(0,href.length-hash.length);
    window.location.href=hash==""?(href+anchorStr):(href.substr(0,href.length-hash.length)+anchorStr);
    }
    </script>
      

  5.   


    那简单阿,调用之前先判断下location含不含comment就行了。
    含的话,先去掉,再加上!