Assigning to [removed].href without clobbering history

前端 未结 6 1239
渐次进展
渐次进展 2020-12-01 19:04

In testing document.location.href, I have observed that when the user initiates an action that results in javascript that assigns to document.location.href, the new URL is a

6条回答
  •  广开言路
    2020-12-01 19:44

    You could change the location without having the browser display a Back button like this:

    window.location.replace(new_url);
    

    However, the original address remains in the browser's history and may be accessed using something like CTRL+H

    Reference:

    • https://developer.mozilla.org/en/DOM/window.location#replace
    • https://developer.mozilla.org/En/DOM/Window.history#Notes

提交回复
热议问题