views:

1895

answers:

2

I've made myself a bookmarklet, and it functions just fine, but when added to a toolbar in Opera or Firefox, it just takes on the default bookmark icon for the browser (a globe and a star, respectively). My site has a favicon, and the window, tab and even [site] bookmark uses the favicon I've specified. Just not my bookmarklet.

How can I code my site or bookmarklet so that the bookmarklet gets the favicon, too?

I'm aware of various manual hackery techniques users can use to set the favicon after the fact, but those are undesirable solutions.

+3  A: 

A bookmarklet uses the javascript:// schema and thus do not have a domain from which a favicon may be loaded.

So, currently there is no way for you to provide a favicon for a bookmarklet. Think about it like this: remember the whole Javascript sandbox thing - where Javascript may not access anything outside the domain of the web page where it is running? Well a bookmarklet that needs to be tied in to whatever domain for the current page you are watching, cannot be also tied in to a favicon on your own web site.

Guss
+1  A: 

That's not quite right: A bookmarklet has no domain, but it has a location (which is the bookmarklet itself) and you can assign an icon to that. After that it's a matter of how the browser saves icons (Firefox saves a bookmark's icon permanently, you may not be so lucky with other browsers).

P.S. Security doesn't even play into it, icons can come from anywhere. There is no restriction.

See http://www.tapper-ware.net/blog/?p=97

Hans Schmucker