Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Permission Denied on script in IFRAME

Status
Not open for further replies.

Craftor

Programmer
Feb 1, 2001
420
NZ
Hi all

I have a document in an iframe. This document is part of an application that resides in a directory beneath the main directory containing the page with the iframe on it i.e.:
test.site.com
- mypage.asp
MyDirectory
- mydocument.aspx

I have the following code on mypage.asp:
Code:
<form action="" method="post" name="frmMain" ID="frmMain">
            <table width="100%" border="0" ID="Table1" cellspacing="0" cellpadding="0" height="100%">
                        <tr>
                                    <td width="100%" height="100%">&nbsp;
                                                <iframe src="MyDirectory/mydocument.aspx?user=<%=strEmail%>" frameborder="0" width="100%" height="100%" id="dynamIframe"></iframe>
                                    </td>
                        </tr>
            </table>
</form>

and the following code in the body tag of mydocument.aspx:

Code:
<body onload="resizeToContent();">

The resizeToContent() function is as follows:
Code:
function resizeToContent()
{
	try
	{
		parent.document.getElementById("dynamIframe").style.height=0;
		var x =0;
		var y =this.document.body.scrollHeight;
		while (x < y)
		{
			x+=1;
		}
		parent.document.getElementById("dynamIframe").style.height=x;
	}
	catch (o)
	{
		alert(o.message);
	}
}

The code is giving a Permission Denied error on the line:

var y =this.document.body.scrollHeight;


I understand that there are security settings in IE for scripting across frames and I have tried to set the document.domain property for both the asp and the aspx page - it gives me the same Permission Denied error in the aspx page...

Can anyone help me with this, please?

Thanks as always


Craftor
:cool:
 
other frames are set into the read-only mode.....

in mozilla and opera there are functions for importing nodes like document.importNode(ndoe, cloneNodes)

but in IE try this one

if(!document.importNode){
document._importNode = function(oNode, bImportChildren){
var oNew;
if(oNode.disabled)
oNode.disabled = false;
if(oNode.nodeType == 1){
oNew = document.createElement(oNode.nodeName);
for(var i = 0; i < oNode.attributes.length; i++){
if(oNode.attributes.value != null && oNode.attributes.value != '')
{
alert(oNode.nodeName + '.' + oNode.attributes.name + " -> " + oNode.attributes.value);
oNew.setAttribute(oNode.attributes.name, oNode.attributes.value);
}
}
oNew.style.cssText = oNode.style.cssText;
} else if(oNode.nodeType == 3){
oNew = document.createTextNode(oNode.nodeValue);
}

if(bImportChildren && oNode.hasChildNodes()){
for(var oChild = oNode.firstChild; oChild; oChild = oChild.nextSibling){
oNew.appendChild(document._importNode(oChild, true));
}
}

return oNew;
}
}
 
Thanks BayK

Unfortunately I had to discard my script idea as we needed to go live urgently but I'll play around with this once I get a bit of free time on the project again.

I will let you know how it goes!

Thanks as always

Craftor

Craftor
:cool:
 
Has anything come of the Permission Denied error...i am seeing this within our portal after upgrading to xp sp2

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
No, unfortunately not. I had to hard code the size and width to amke it work.
 
The line you say you're getting the error on is NOT cross-frame. It's accessing its OWN document. That shouldn't cause an error. Are you sure you need the "this." before "document"?


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top