Potential problems setting [removed].hash

后端 未结 5 590
故里飘歌
故里飘歌 2020-12-15 05:02

I have some javascript code which, at one point, sets window.location.hash to a specific string. This works fine in Firefox 3, but I want to know if I will run

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-15 05:34

    Setting window.location.hash works fine in IE6 & IE7.

    In some occasions, reading window.location.hash under IE6 right after a set will return the old value, but the browser has set the hash successfully. An example:

    alert(window.location.hash);
    window.location.hash = '#newHash';
    
    /* Sometimes, it will return the old value,
       I haven't figured out why it does that, and
       it's rather rare. */
    alert(window.location.hash);
    

    If you are just using it to set it, you shouldn't run into any problems.

提交回复
热议问题