Assigning to [removed].href without clobbering history

前端 未结 6 1221
渐次进展
渐次进展 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

    URL can be manually added to history before redirecting the user.

    if (window.history) {
        history.pushState({}, window.location.href);
    }
    window.location.replace("/login/?next=" + window.location.pathname);
    

提交回复
热议问题