mmc98dl1
asked on
IFRAME resizing
Hi all,
I have a small piece of JS to resize IFRAME's within the same domain so that the iframe doesnt scroll. The js is within the iframe.
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
//-- Frame Handling Script - Wax Interactive - May 2005
function resizeIframe() {
minFrameHeight = 250;
contentHeight = document.body.scrollHeight ;
if (minFrameHeight > contentHeight) contentHeight = minFrameHeight;
this.parent.document.getEl ementById( "contentFr ame").styl e.height = contentHeight;
if (this.parent.document.getE lementById ("contentF rame").sty le.height)
this.parent.document.getEl ementById( "contentFr ame").scro lling = "no";
}
document.domain = "adage.com.au";
parent.window.scroll(0,0);
//-- End Frame Handling Script
//-->
</SCRIPT>
<iframe name="contentFrame" id="contentFrame" src="http://jobs.adage.com.au/" style="border: 1px white solid;" width="100%" height="1000" frameborder="0" scrollbars="0">
<p>Your browser needs to support I-FRAMES in order to view this area of the website.<br>
Please download one of the following browsers:</p>
<p><a href="http://www.microsoft.com/ie" target="_blank">Microsoft Internet Explorer</a><br>
<a href="http://www.mozilla.org/products/firefox/" target="_blank">Mozilla Firefox</a>
</p>
</iframe>
You can see this in action at http://www.adage.com.au/findajob.asp and it works just great.
I have now had some trouble in applying the same thing to a different site.
http://www.hireinsight.com.au/jobseeker.html - original code.
http://www.hireinsight.com.au/iframe.html - trial of the adage.com.au code on hireinsight.com.au
http://www.hireinsight.com.au/iframe2.html - trial of iframe on balnk page.
Can anyone see why this isnt working?
I have a small piece of JS to resize IFRAME's within the same domain so that the iframe doesnt scroll. The js is within the iframe.
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
//-- Frame Handling Script - Wax Interactive - May 2005
function resizeIframe() {
minFrameHeight = 250;
contentHeight = document.body.scrollHeight
if (minFrameHeight > contentHeight) contentHeight = minFrameHeight;
this.parent.document.getEl
if (this.parent.document.getE
this.parent.document.getEl
}
document.domain = "adage.com.au";
parent.window.scroll(0,0);
//-- End Frame Handling Script
//-->
</SCRIPT>
<iframe name="contentFrame" id="contentFrame" src="http://jobs.adage.com.au/" style="border: 1px white solid;" width="100%" height="1000" frameborder="0" scrollbars="0">
<p>Your browser needs to support I-FRAMES in order to view this area of the website.<br>
Please download one of the following browsers:</p>
<p><a href="http://www.microsoft.com/ie" target="_blank">Microsoft Internet Explorer</a><br>
<a href="http://www.mozilla.org/products/firefox/" target="_blank">Mozilla Firefox</a>
</p>
</iframe>
You can see this in action at http://www.adage.com.au/findajob.asp and it works just great.
I have now had some trouble in applying the same thing to a different site.
http://www.hireinsight.com.au/jobseeker.html - original code.
http://www.hireinsight.com.au/iframe.html - trial of the adage.com.au code on hireinsight.com.au
http://www.hireinsight.com.au/iframe2.html - trial of iframe on balnk page.
Can anyone see why this isnt working?
Or in other words, cross domain access id forbidden.
So as soon as parent window and i´frame are different internet domains you cannot read none of the attributes of the other domain.
All you can do is to set window.location or window.frames.iframeName.l ocation
But you cannot even read the actual location.
So as soon as parent window and i´frame are different internet domains you cannot read none of the attributes of the other domain.
All you can do is to set window.location or window.frames.iframeName.l
But you cannot even read the actual location.
ASKER
>>It is not working because you try to set a foreign domain:
document.domain = "adage.com.au";
Can you be more specific? In which example is this the case - as far as I am aware none of them use incorrect domains.
You will notice that we set adage.com.au on the adage.com.au iframe. On the hireinsight.com.au domain we set the hireinsight.com.au inside the iframe.
You will see that on http://www.adage.com.au/findajob.asp the code is all correct and that it works fine.
You will also see on http://www.hireinsight.com.au/jobseeker.html that the code is exactly the same and there is no difference apart from the domain.
My question is why does the adage.com.au work and hireinsight.com.au doesnt work???
document.domain = "adage.com.au";
Can you be more specific? In which example is this the case - as far as I am aware none of them use incorrect domains.
You will notice that we set adage.com.au on the adage.com.au iframe. On the hireinsight.com.au domain we set the hireinsight.com.au inside the iframe.
You will see that on http://www.adage.com.au/findajob.asp the code is all correct and that it works fine.
You will also see on http://www.hireinsight.com.au/jobseeker.html that the code is exactly the same and there is no difference apart from the domain.
My question is why does the adage.com.au work and hireinsight.com.au doesnt work???
ASKER
>> cross domain access id forbidden.
I know that - the js is dynamically created in a ColdFusion page which reads the URL of the iframe domain. it then puts this into the js and (in the case3 of adage.com.au) it resizes because the domains are in line.
Why does the same thing not work on hireinsight.com.au?
Why does it not work on http://www.hireinsight.com.au/iframe2.html - a completely blank page with all the correct domain info???
I know that - the js is dynamically created in a ColdFusion page which reads the URL of the iframe domain. it then puts this into the js and (in the case3 of adage.com.au) it resizes because the domains are in line.
Why does the same thing not work on hireinsight.com.au?
Why does it not work on http://www.hireinsight.com.au/iframe2.html - a completely blank page with all the correct domain info???
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome.
ASKER
Thanks - I couldnt see it, I knew there was a reason!!
:-)
document.domain = "adage.com.au";
That is not allowed.
Try setting this:
document.domain = "hireinsight.com.au";