I'm using an iframe
, and I have a back button which runs this javascript code (when user clicks on back button):
document.getElementById("myframe").contentWindow.history.go(-1); // back
This works fine, but If there is no previous page in the frame, main page will go back.
How to avoid this? I want just iframe to go back, and if there is no previous page, simply do nothing.
EDIT: This is my code. (@ jsfiddle)