Can a web app in xul:iframe access functions from its parent XUL file?
- by oskar
I want to deploy a web app as a self-contained program using XULRunner. I'm simply loading it in a xul:iframe tag within the main XUL file. It works, but I want the web app to have access to XUL components, specifically nsiFilePicker.
My tentative solution is to run the xul:iframe with escalated privileges (by omitting the "type" attribute), wait for the xul:iframe to load, then define a javascript function that the web app will then call.
<window id="main" width="800" height="600" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<iframe id="contentview" src="web/index.html" flex="1"/>
<script>
//listen for XUL window to load
window.addEventListener("load",Listen,false);
function Listen()
{
var frame = document.getElementById("contentview");
frame.addEventListener("DOMContentLoaded", DomLoadedEventHandler, true);
}
//listen for iframe to load
function DomLoadedEventHandler() {
//set function in iframe called testMe()
var frame = document.getElementById("contentview");
frame.contentWindow.testMe = function () {
alert("This is a test");
};
}
</script>
</window>
...and then in the index.html file of the web app...
<script>
testMe();
</script>
This doesn't seem to work. Does anyone have any suggestions?