nomadicME
nomadicME

Reputation: 1409

Reloading a loaded plugin

I followed the directions found here:

http://www.firebreath.org/display/documentation/Tips+and+Tricks#TipsandTricks-Reloadingaloadedplugin

and this is the block that I added to FBControl.htm for FBTestPlugin:

    var myplugin = "<object id=\"plugin0\" type=\"application/x-fbtestplugin\"> </object>";

    function onload(){ // You must call this after the page loaded.
     document.getElementById('plugin0').innerHTML = myplugin;
    }

    function reload(){
     document.getElementById('plugin0').innerHTML = "";
     document.getElementById('plugin0').innerHTML = myplugin;
    }

Then after refreshing the page in chromium, I run onload() from the JS console. It returns "undefined", and I know the plugin is stale because I changed getSomeInt to another integer before the last build and it returns the old one. I've also tried disable/enable the plugin in the chromium preferences page, same result.

First question: What is wrong with the above code block / why does it return "undefined"?

Second question: Is there another way to manually reload the plugin, besides restarting the browser?

Upvotes: 0

Views: 658

Answers (1)

Max Amanshauser
Max Amanshauser

Reputation: 73

1) You misuse the ID 'plugin0'. The page says

 var myplugin = "<object id=\"plugin\" type=\"application/x-foobar\"> </object>";
 ...
 document.getElementById('pluginhere').innerHTML = myplugin;
 ...
 <div id="pluginhere"></div>

Pay attention to the IDs, you want to put the <object> in the <div>.

Plus: Before you call your reload() function you need to call navigator.plugins.refresh(false); to make the browser reload the list of available plugins.

Furthermore: I found that this way of reloading loaded plugins works well. Until it doesn't. Sometimes (rarely) it will stubbornly use the old plugin (tested with Chrome). I updated the docs to reflect that.

2) You can crash your plugin and reload the page. Good for developing, but nothing else. Using this in production will send you straight to hell.

Upvotes: 2

Related Questions