I have page1 that contains an object tag that loads page2. Thing is, when opening page1 I need to hide a specific div in page2 when the the object tag loads it. Otherwise, when opening the page2 from a browser it should appear normally.
My html and javascript code look like this:
page1.html
<html>
....
<div id="myUrl">load object tag here</div>
<script>
...
document.getElementById("myUrl").innerHTML = '<object type="text/html" width="500px" height="500px" data="path/page2.html" ></object>';
</script>
</html>
What I need is to hide mydiv if page2 is loaded in the object tag in page1:
page2.html
<html>
....
<div id="mydiv"><h3>test title</h3></div>
....
<script>
//if opened from htmlpage1 hide the div
$("#mydiv").hide();
</script>
</html>
After doing some research I came up with two possible ideas:
- Using the param tag inside in page1 and check its value in page2 to hide mydiv
- or have a javascript method in page2 that checks if the document (#document) is a child/inside of object.
I have been struggling to implement any of these ideas but with no success. I would appreciate it if someone could help me with this. Thank you.
<object>to load html page?