Linked Questions

Popular Questions

I have a page which contains another page embedded inside an object tag. Now I want to call a javascript function from the "parent"-page. To be specific: The parent page wants to call a function, which resides inside the embedded code. Former I used iframes but they caused some nasty bugs with Firefox, so I don't want to use them anymore.

Edit: So, my question is: what would be the best way to achieve this, when using an object tag?

Here's some example to illustrate what I want to do:

I have a HTML page "parent.html" inside this page there is some Javascript inside a tag. This parent.html also has an tag and the src of this tag is another HTML page, let's call it child.html. The child.html page has something like:

Here's some pseudo code:

in Child.html:

<script type="text/javascript" src="child.js"></script>

in Child.js:

function getSomething(){
    return something;

in Parent.html:

<object id="childObject" data="child.html" width="850" height="510">

    // Here I want to access the function from the child.js
    // I tried something like this, but it doesn't work:
    var something = document.getElementById('childObject').contentDocument.getSomething();

Now: In the Javascript inside the parent.html I need to call a function from the child.js. How can I achieve this?

Thank you :)

Related Questions