“[removed].hash = location.hash” does not work in Webkit (Safari & Chrome)

前端 未结 5 973
一向
一向 2021-01-12 06:14

I can\'t get window.location.hash = location.hash to work in Safari.

I\'m using javascript to wrap the contents of my page with a scrollable DIV, placed

5条回答
  •  日久生厌
    2021-01-12 06:49

    Before JavaScript changes the orginal hash location, get the scroll position using

    var st = $(window).scrollTop().
    

    When you want to restore the scroll location, use

    $(window).scrollTop(st);
    

提交回复
热议问题