Discussion:
how to get favicon url?
k***@gmail.com
2008-06-29 23:06:49 UTC
Permalink
Let's say that my XUL app has <browser> element. How can I get now an
URL pointing to favicon of google.com? google.com was loaded some time
ago and should be present in cache (as well as its favicon).

The following example doesn't work

/******************************************************/

const mlFIS = Components.classes["@mozilla.org/browser/favicon-
service;1"]
.getService(Components.interfaces.nsIFaviconService);
const mlIOService = Components.classes["@mozilla.org/network/io-
service;1"]
.getService(Components.interfaces.nsIIOService2);

var mURI;

mURI = mlIOService.newURI("http://google.com", null, null);

try
{
mURI = mlFIS.getFaviconForPage(mURI);
}
catch(e)
{
alert(e);
mURI = {};
mURI.spec = "<no>";
}

alert(mURI.spec);

/******************************************************/

It raises exception

[Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIFaviconService.getFaviconForPage]"
nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)
Philip Chee
2008-07-01 04:58:37 UTC
Permalink
Post by k***@gmail.com
Let's say that my XUL app has <browser> element. How can I get now an
URL pointing to favicon of google.com? google.com was loaded some time
ago and should be present in cache (as well as its favicon).
[...]
Post by k***@gmail.com
[Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIFaviconService.getFaviconForPage]"
nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)
You will either have to implement the favicon service or implement the
equivalent functionality.

Phil
--
Philip Chee <***@aleytys.pc.my>, <***@gmail.com>
http://flashblock.mozdev.org/ http://xsidebar.mozdev.org
Guard us from the she-wolf and the wolf, and guard us from the thief,
oh Night, and so be good for us to pass.
[ ]If love is blind, why is lingerie so popular?
* TagZilla 0.066.6
pooco666
2008-07-01 20:26:03 UTC
Permalink
Post by Philip Chee
Post by k***@gmail.com
Let's say that my XUL app has <browser> element. How can I get now an
URL pointing to favicon of google.com? google.com was loaded some time
ago and should be present in cache (as well as its favicon).
[...]
Post by k***@gmail.com
[Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIFaviconService.getFaviconForPage]"
nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)
You will either have to implement the favicon service or implement the
equivalent functionality.
Phil
--
Guard us from the she-wolf and the wolf, and guard us from the thief,
oh Night, and so be good for us to pass.
[ ]If love is blind, why is lingerie so popular?
* TagZilla 0.066.6
I know this may not be the answer you are looking for but if you are
looking to grab favicons of sites before you load them, perhaps the
best way is to CURL the site. Use CURL to read the headers and
determine the favicon location, then load in the favicon wherever you
wish. Create it as a service to cache the images and access it via
ajax or just preload them via the backend.

Loading...