将书签拖到工具栏时如何设置收藏夹图标/图标? [英] How to have favicon / icon set when bookmarklet dragged to toolbar?

查看:37
本文介绍了将书签拖到工具栏时如何设置收藏夹图标/图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为自己制作了一个书签,它运行良好,但是当添加到 Opera 或 Firefox 中的工具栏时,它只会采用浏览器的默认书签图标(分别是地球仪和星形).我的网站有一个收藏夹图标,窗口、标签甚至 [站点] 书签都使用我指定的收藏夹图标.只是不是我的书签.

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.

推荐答案

书签使用 javascript:// 架构,因此没有可以从中加载收藏夹图标的域.

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

因此,目前您无法为书签提供收藏夹图标.可以这样想:记住整个 Javascript 沙箱的事情 - Javascript 可能无法访问它运行的网页域之外的任何内容?一个书签需要绑定到您正在观看的当前页面的任何域,不能同时绑定到您自己网站上的网站图标.

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.

更新:根据 Hans Schmucker 的回答,有可能创建一个书签,当浏览器将其加载到书签菜单时,它将生成一个带有 favicon 的 HTML 文档.推理似乎可行,但我还没有看到类似的事情发生,而且我的测试结果为阴性.

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.

这篇关于将书签拖到工具栏时如何设置收藏夹图标/图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆