dpDesignz
dpDesignz

Reputation: 1957

Javascript not running on site

On the following site (http://www.homefresh.co.nz/gallery.html) there is a piece of javascript up the top to dynamically change the height of my iFrame

Javascript in header:

<script type="text/javascript" language="javascript">
<!--
function calcHeight()
{
    //find the height of the internal page
    var the_height=document.getElementById('the_iframe').contentWindow.document.body.scrollHeight;
    //change the height of the iframe
    var the_height = parseFloat(the_height) + 15;
    document.getElementById('the_iframe').height=the_height;
}
//-->
</script>

and in the page is the iFrame code:

<iframe src="http://www.dpdesignz.co.nz/homefresh/" id="the_iframe" onLoad="calcHeight();" height="1" width="920px" scrolling="auto" frameBorder="0"></iframe>

except for some reason it's not updating

I have the exact same code here and it works (http://www.dpdesignz.co.nz/homefresh/test.htm)

Can anyone see anything stopping it?

Upvotes: 0

Views: 183

Answers (1)

Łukasz W.
Łukasz W.

Reputation: 9755

The page with script and the iframe page have to be on the same domain. This is required by the same Same origin policy because of security matters.

So if you want to access document that's on www.dpdesignz.co.nz then you have to use host page that is on www.dpdesignz.co.nz domain. That's why one of your scripts works and the other don't.

Upvotes: 3

Related Questions