I was looking for the answer to this question, but I can’t figure out how to do it.
I want to access the contents of a div that I have included in an object tag.
My include.htm file:
<div id="includedDiv">This is the included page</div>
What I tried:
<html>
<head>
<title>Get element from object included page</title>
</head>
<body>
<p>Test: This is the main page</p>
<object id="obj" data="include.htm"></object>
<script>
alert(document.getElementById("obj")["includedDiv"]);
</script>
</body>
</html>
Not a single warning gives me the message "This is an included page", is there a way to get this content from the DOM?
EDIT: Window [0] .document.getElementById ("includedDiv") firstChild.nodeValue. was a good response to access through the DOM, the object tag simply creates another window :)
http://www.w3schools.com/jsref/prop_win_length.asp
baptx source
share