1

I have a main page that contains several iframes and those iframes also have multiple iframes. iframes load with dynamic data.now the requirement is that when i click on the back button of browser then that give an alert(this functionality is not allowed). so that the previous iframe can't load. so how can i do this??

V.T
  • 11
  • 1
  • 2

2 Answers2

1

Based on iFrame purpose which is an HTML document embedded inside another HTML document. So an IFrame behaves like a window with its own independent content. In jQuery I did this and works for me. hope that would be useful.

$(window.parent.window).on('popstate', function () {               
    //Some codes
});

But should know that "popstate" event of the window is fired when the active history entry changes. So it works for both backward and forward navigation.

Ali Tabandeh
  • 86
  • 1
  • 3
0

assuming you have no prior condition to check iframe content

window.onbeforeunload = function() {
    return 'this functionality is not allowed';
}
A.T.
  • 24,694
  • 8
  • 47
  • 65