Link to home
Start Free TrialLog in
Avatar of LissiS
LissiSFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Permission denied to get property HTMLDocument.getElementById when resizing iframe

I'm trying to get a JS script working which will resize an iframe containing my content to my client's webpage.  The CMS for their website is located on the same linux server as my tomcat installation, and both are accessed from www.<their website>.com (although of course, mine is derected to the 8080 port for tomcat.)

The HTML in their CMS to link to my content is:

<iframe id="the_iframe" src="<Their website>:8080/formswizard/showWizardForm.do?formName=personalDetails" frameborder="0" width="100%" height="500px">Sorry your browser does not support our quotations, please call <tel number> for our telephone service</iframe>

The JS to resize is (Called from an init() function which is called onLoad()):

function calcHeight()
{

var newheight;      

if(navigator.appName=="Microsoft Internet Explorer")
{
newheight=parent.document.getElementById('the_iframe').contentWindow.document.body.scrollHeight;
parent.document.getElementById('the_iframe').height= newheight;
}
else if(navigator.appName=="Netscape")
{
newheight=parent.document.getElementById('the_iframe').contentDocument.documentElement.offsetHeight;
parent.document.getElementById('the_iframe').style.height = (newheight +16) + "px";
}

}

When loading up their webpage with my content linked through, I get the error uncaught exception: Permission denied to get property HTMLDocument.getElementById, which is the same error as when they were on different servers.  I was hoping that by moving them onto the same linux serer, it would solve this problem.  Is there any way I can get this current setup to function correctly, or any workarounds I could use?

Thanks,

Lissi
ASKER CERTIFIED SOLUTION
Avatar of CarlBoro
CarlBoro
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't know of a simple way with sites not on your domain. Javascript should give you a Permission Denied error in that case, because Javascript is not allowed to run cross-site.