Using JavaScript to change the URL used when a page is bookmarked

后端 未结 6 562
误落风尘
误落风尘 2021-01-14 05:55

JavaScript doesn\'t allow you to update window.location without triggering a reload. While I agree with this policy in principle (it shouldn\'t be possible to

6条回答
  •  旧巷少年郎
    2021-01-14 06:08

    As mentioned, generally with ajaxy sites, you manipulate/check the hash part of the URL (window.location.hash) to determine this kind of activity.

    The biggest issue is making sure to check against the hash in DOM-ready/window-load, as if the user clicked on a given image. This will work with browsers and bookmarks, but may hamper search indexing.

提交回复
热议问题