javascript - location.replace not replacing current url in history -


i have following code executed on button click:

location.replace(window.location.href.split('?')[0] + _new_urli); 

my url looks like: https://mywebsite.com/website/?page=page1

for sake of example have:

current behavior: after location.replace() current url stays in history , user can click it

desired/intended behavior: if successful user forwarded. if press not able visit page used location.replace on.

this described functionality on: http://www.w3schools.com/jsref/met_loc_replace.asp

you use historyof navigation.

something history.go(-2); should work.

if want modify url can have @ history.pushstate(null, null, "newurl"); or in case more history.replacestate().

the thing button not keep change if data changed on page 3 need other way pass browser state object (the first parameter null) can set {object: value,...}

this while interest too. thing without knowing behaviour of site difficult find proper solution. hope inspire you.


Comments