Hello all,
Hoping someone can help me with a little problem...
I am building an XUL app composed of a chrome window with an iframe.
When I first open run the app an html document is loaded from a URL into the iframe. In this html document I have a button as follows:
<input type="button" onclick="window.parent.testFunc()"/>
When I click the button it runs the testFunc() function which resides in the <script> tag of the chrome window. Very simple, no problems.
Here is where it gets weird... I want program to build a webpage on-the-fly and load/write it into the iframe. So I have this code in the javascript of my chrome window:
var doc = window.frames["doc"].document;
doc.open( );
doc.write("<html><body onclick="window.parent.testFunc();">Just a test sentance.</body></html>");
doc.close( );
That document is prolly for the URL about:blank.
The html page that I create is written and displayed in the iframe as expected, however if I call the function window.parent.testFunc(); from within the generated html page it gives the following error in the javascript console:
Error: uncaugth exception: premission denied to get property ChromeWindow.testFunc
This happens with any function I try to call that resides in the Chrome Window, and it only happens when the page in the iframe has been generated instead of loaded from a URL. Is there a way to get around this "security" issue? I've tried calling netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); before calling the function but then I get the error that the permission requested was refused. Help.
Yes, this is a security issue. about:blank is not allowed to access chrome:// or any other site (if you're not actually doing chrome:// stuff, but remote xul).
One way to work around this would be to use a dummy html document in the iframe and just modify the parts that change.
If you wanna work with netscape.security foo, you should ask for UniversalBrowserRead instead of XPConnect. As you actually want to read, instead of creating a class instance or so.
Axel
thanks. mawrya
