How to access your plug-in’s ressources

There are times where you need to know the URL of a ressource within your plug-in. An example is when you want to embedded an applet and add it to your page, or get the link to an image. In order to do that, you can use the following code:

Request.getPluginResourceUrl("PluginName", "myFolderWithingWebContentFolder/path");

An example if you want to embedded an applet:

var appletHTML = '<applet alt="MyApplet" name="MyApplet" width="1px" height="1px" code="my.package.MyClass.class" codebase="'
    + Request.getPluginResourceUrl('PluginName', 'applets')
    + '" archive="MyApplet.jar" mayscript="true">';
appletHTML = appletHTML + '</applet>';
appletDiv = document.createElement("div");
appletDiv.innerHTML = appletHTML;
applet = appletDiv.firstChild;

That can be convenient .

Leave a Reply