Really hope someone can help me with this. Have been trawling the web and breaking my head over this. I basically want to load an Applet inside an XUL file. The Applet has been packaged into a JAR and signed. I tried using IFRAME with the applet in an HTML file. Tried APPLET, EMBED and OBJECT tags. Even tried getting the absolute path and dynamically building/setting the Applet properties. I have Java 6 installed. No go! Its the same error everytime ...
java.net.MalformedURLException: unknown protocol: chrome at java.net.URL.<init>(Unknown Source) at java.net.URL.<init>(Unknown Source) at java.net.URL.<init>(Unknown Source) at sun.plugin.AppletViewer.getDocumentBase(Unknown Source) at sun.plugin.AppletViewer.getCodeBase(Unknown Source) at sun.plugin.AppletViewer.createClassLoader(Unknown Source) at sun.plugin.AppletViewer.appletInit(Unknown Source) at sun.plugin.viewer.LifeCycleManager.initAppletPanel(Unknown Source) at sun.plugin.viewer.WNetscapePluginObject$Initer.run(Unknown Source)
Actually is it possible in Firefox to make an Applet dynamically use the file:/// protocol instead of chrome://? Have been at it for days and looks more and more like its impossible.
How does Mozilla parse the <APPLET> tag and the corresponding attribute "codebase"? There should be some way to make the engine into using the "file" protocol instead of "chrome" just in this case. Is there a mapping which can be set somewhere which can map a particular chrome url to a relative path?
From the errors it looks like java (<APPLET> tag) can't find the file using a chrome url.
Should be able to open a file: url from a local page (file:, chrome:) A web based page won't. Try use relative url for the applet (just file name) in the html, and put applet and html in a top level folder of .xpi. Then you can load the file: url of the html into the .contentDocument.location.href of the iframe.
// your extension's guid (change this) var guid = "sample@max.max"; // name of folder to get (change this) var folderName = "sample"; // name of file to get (change this) var fileName = "sample.htm";
var file = Components.classes["@mozilla.org/extensions/manager;1"] .getService(Components.interfaces.nsIExtensionManager) .getInstallLocation(guid) .getItemLocation(guid); file.append( folderName); file.append(fileName); var url = makeFileURI(file).spec;
// load in current page content.document.location.href = url; // load in iframe page (your iframe) // iframe.contentDocument.location.href = url;
Last edited by max1million on December 30th, 2008, 11:39 pm, edited 1 time in total.
Brilliant! It worked! Thanks max1million. I had tried everything except dynamically loading the iframe src. I now use JSObject and chained calls to the parent javascript function. Heres my code now:
mozillaZine is an independent Mozilla community and advocacy site. We're not affiliated or endorsed by the Mozilla Corporation but we love them just the same.