I’m attempting to use document.location(.href) on the onLoad event to redirect from one page (A) to another (B).
From my understanding, if I use document.location.href (as opposed to .replace), it should add (A) to my history. However, this doesn’t appear to be happening.
I’ve tried setting document.location, document.location.href, and using .assign, and none of these seem to add the first page to the history. Is there any JS technique that can be done via onLoad that will cause (A) to be in the history?
Cheers,
Victor
If you modify document.location.href, it will definitely add to the history.
Try this demo page →
Code:
Can you create a sample page where it shows that browser history is not changed?