Discussion:
generated iframe accessing parent property : access denied
freddy81
2005-03-07 13:24:34 UTC
Permalink
Hi,

i have read a lot of thing about frames and cross domain security and i
don't know how i can do this in mozilla :

i have an xsl file which transform an xml file into an html. this
result is added to my document body of the iframe. In this body, i want
to access to parent property (ex : parent.document.title) and i have an
"access denied to HTMLDocument.title"

Ok, so i'm tried to change security user pref with
netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesRead
UniversalPreferencesWrite");

and I get this error : uncaught exception: Un script de
« about:blank » s'est vu refuser des privilèges
UniversalPreferencesRead UniversalPreferencesWrite.

Another important thing is i must not specify a src for the iframe
because i fill it dynamicaly.

And all of this work in IE6, that's my problem !

I do not have any idea how i can find a solution.

Fred,

Sorry for my english, i'm french ! lol
Martin Honnen
2005-03-07 14:40:25 UTC
Permalink
Post by freddy81
i have read a lot of thing about frames and cross domain security and i
i have an xsl file which transform an xml file into an html. this
result is added to my document body of the iframe. In this body, i want
to access to parent property (ex : parent.document.title) and i have an
"access denied to HTMLDocument.title"
Are the document in the iframe and the document in the parent window
loaded from different servers?
Can you post a URL where the problem occurs?
--
Martin Honnen
http://JavaScript.FAQTs.com/
freddy81
2005-03-07 15:17:34 UTC
Permalink
My work works well if I specify an empty but real src to the iframe ...
So documents are loaded from same server (files are on the same local
directory). but I try to not specify src to only have a memory document
for iframe !

I loaded and transform this xml by the xsl and store it to the parent
body .
=====
xsl
=====

<xsl:template match="/">
<iframe id="testiframe" name="testiframe"
onload="fillpage(this)"></iframe>
</xsl:template>


=====
xml
=====

<hello/>

=====
javascript
=====

function fillpage (iframe) {
var xmldoc = document.implementation.createDocument("", "",
null);
var xsldoc = document.implementation.createDocument("", "",
null);
xmldoc.async = false;
xsldoc.async = false;
xmldoc.load("test2.xml");
xsldoc.load("test2.xsl");
var proc = new XSLTProcessor ();
proc.importStylesheet(xsldoc);
var resultdoc = proc.transformToFragment(xmldoc, document);
var myframe = frames[iframe.name];
myframe.document.body.appendChild(resultdoc);
}

then I transform another xml with another xsl and store result into
iframe body !

====
xsl 2
====

<xsl:template match="/">
into iframe !
<script language="javascript" defer="defer">
function testme () {

netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesRead
UniversalPreferencesWrite");
alert(parent.document.fillpage)
}
</script>
<input type="button" value="click" onclick="testme()"/>
<script defer="defer">alert(parent.document.title)</script>
</xsl:template>

=====
xml 2
=====

<hello/>

My goal is not to access parent document title but parent's javascript
functions and global variables !

Fred, I hope you can help me

Sorry i cannot post a url, no website ...

Loading...