i have the following webpage:
<!Doctype html>
<html>
<head>
<script>
function display(value){
document.getElementById('displayer').src=value;
return false;
}
</script>
</head>
<body>
<form name="x" onsubmit="return display(this.y.value)">
<input name="y" /><input type="submit" value="display"/>
</form>
<iframe id="displayer">ERROR</iframe>
<button onclick="document.getElementById('displayer').contentWindow.history.back()">Click me to go back in the history of iframe!</button>
</body>
</html>
and the back button works fine, but when someone reaches the page they started with (in the iframe) and they click the back button it takes them to the previous page they visited in the whole browser window. how can i somehow disable the back button when someone reaches the page they started with?
i can keep track of the page they started with by using the value in the textbox, but how to know which page is currently being visited in the iframe?
if i can know which page is currently being visited in the iframe then i can easily put a conditional statement to disable the button...
i've tried:
document.getElementById("displayer").contentWindow.location.href
but it gives me undefined!
i am working on ubuntu 12.10 on google chrome latest version.
please help...
EDIT
Answers to both questions asked:
how can i somehow disable the back button when someone reaches the page they started with?
You can't.
how to know which page is currently being visited in the iframe?
In this case, there isn't a way.
For security reasons, just like you can't fetch content with AJAX from a source outside your site, you can't get the iframe
url if outside your site.