This Planet is a Tedious Place...

16/01/12 How to detect an installed Chrome extension in a normal web page?

I searched for a while and was struggling to come up with a way to do this. Several people were suggesting that the extension should write an element into the page using a content script and then page could the check for it's existence. This seemed a bit inelegant and would also require a new version of the extension.

Then I found this gem from Gildas on the Chromium forums, which attempts to load an image resource from the extension:

function detectExtension( extensionId, callback )
var img;
img = new Image();
img.src = "chrome-extension://" + extensionId + "/icon16.png";
img.onload = function() { callback( true ); };
img.onerror = function() { callback( false ); };

Works a treat - just make sure that the file referenced, icon16.png in this case, is present in your extension folder.

posted by Gruntfuggly # 22:32 1 comment

Very good info buddy i ve used animated favicon on my site too :D

Somebody # 13/11/12 01:27

Somebody # 28/06/17 09:42


Add Comment