Good day to all.
I have this structure
<html>
<iframe>
<div id="idd">Some Content</div>
</iframe>
<script type="text/javascript">
function getIddContent()
{
//This is the part I ask about
}
var content = getIddContent()开发者_开发知识库;
</script>
</html>
I need to get the content of the div inside the content variable. Thank you for your time. If I use document.getElementById("idd").innerHTML it says that the div doesn't exist.
Use the following code
function getIddContent() {
return window.frames[0].document.getElementById('idd').innerHTML;
}
But you probably have to include the iframe contents via the src attribute on the iframe.
精彩评论