1

I have the following code:

<div id="hello">
    <iframe stc="foo/bar.html"></iframe>
</div>

Contents of iframe:

<!DOCTYPE html>
<html>
<body>
    <div id="foo"></div>
</body>
</html>

How can I get the div with id "hello"?

If all this was on the same page I would do something like:

document.getElementById('foo').parentNode;

Note: I can't use jQuery for this project. Also I can't select by id because I don't know what the id of that parent would be. If it would have always been foo then I could have done:

parent.document.getElementById('foo')

1 Answers1

0

Can you select element by class name? If so, here's a way of doing that: http://www.anyexample.com/webdev/javascript/javascript_getelementsbyclass_function.xml

Kon
  • 27,113
  • 11
  • 60
  • 86