Solution 1 :

Loading iframes shouldn’t automatically add to browser history. You could search for occurrences of history.pushState to see if the code is explicitly adding to history.

As a hack, if your code executes before history is altered, you could do something like

let oldLength = history.length;

// go back to previous page
$(document).on('click', '.back', function () {
    let currentLength = history.length;
    window.history.go(oldLength - currentLength - 1);

Problem :

It sounds weird, but I have a back button that use JS method window.history.back(), all I want is to go back to the previews page. I noticed, when I click to see the customer’s detail page, where my “back button” exist, if I click before loading the entire document, the button works OK,I mean, just one click, and it returns to the page I was before. But if I wait until the documento is full downloaded, it icludes 3 iframes , then I have to click on the “back button”, 4 times to return one page.
This is the button code:

<a class='btn back pull-right' style='background-color: #45B6AF;color:#ffffff;'>Back</a>

I use the class back, and this is the JS part (extenal js file):

// go back to previous page
$(document).on('click', '.back', function () {


Any ideas, I have been with this for two days !!!


Comment posted by Marked as Duplicate

Iframes can create new entries to the browser history. If you’re setting the iframes through JS, try using something like

Comment posted by CaribeSoft

Yes!, that was an excellent idea, problem resolved. I was missing that on iframes load, was affecting the history length, thank you very much Jeril !