I have a page which contains an iframe and I want to track the history of the iframe only. I tried to use the history object like this:
If the frame contains contentWindow, you can use frame.contentWindow.history.
But not all browsers support this property. If not, the frame's location should be stored in some variables. Bind event handler on your frame onload event like below(using jquery)
var frameHistory = [];
$(document).ready(function(){
var frame = window.frames["test2"];
$.bind(frame, "onload", function(){ //store location when frame loads
frameHistory.push(frame.window.location.href);
}
});
And in your button click event handler:
alert(frameHistory.length);