Modify iframe.src without entry to history object
don't change the src, just replace the old iframe with a new one?
const urls = [
"http://bing.com",
"http://google.com",
"http://duckduckgo.com"
];
function next() {
if(urls.length==0) return;
const original = document.getElementsByTagName("iframe")[0];
const newFrame = document.createElement("iframe");
newFrame.src = urls.pop();
original.parentNode.replaceChild(newFrame, original);
}
nextbtn.addEventListener("click", () => next());
iframe {
width: 300px;
height:300px;
}
<p>let's test some iframes</p>
<button id="nextbtn">next</button>
<iframe />
No history states. Same functionality. Everyone wins.