On my website, there is a parent page containing two iframes. Everything is set up as I want it, except for one issue when using the browser's back button - only one of the iframes updates its content. I am attempting to implement a check within the child frames to ensure that the correct content page loads in the other iframe (referred to as leftiframe and rightiframe).
Here is the code I have been working on, but it is not functioning as intended:
<script type="text/javascript">
window.onload = function() {
if(/iframe1.html/.test(parent.leftiframe.location.href))
{
}
else
{
parent.leftiframe.location.href="iframe1.html";
}
}
</script>
If I modify the code to read the URL from the current window like this:
if(/iframe2.html/.test(window.location.href))
it successfully reads the URL and updates the sister iframe without any problems. Why does replacing window with parent.leftiframe result in issues?
Any help would be greatly appreciated!