How to have favicon / icon set when bookmarklet dragged to toolbar?

后端 未结 9 1919
有刺的猬
有刺的猬 2020-12-02 05:03

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 g

9条回答
  •  自闭症患者
    2020-12-02 05:15

    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.

    Update: According to Hans Schmucker's answer, there is a possibility to create a bookmarklet that when loaded by the browser into the bookmark menu it will generate an HTML document that has a favicon. The reasoning seems like it may work but I have yet to see something like this in action and my tests have came back negative.

提交回复
热议问题