Firefox javascript 书签问题
我正在使用以下 JavaScript 代码:
<script language="JavaScript1.2" type="text/javascript">
function CreateBookmarkLink(title, url) {
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
} else if( window.external ) {
window.external.AddFavorite( url, title); }
else if(window.opera && window.print) {
return true; }
}
</script>
这将为 Firefox 和 IE 创建书签。 但 Firefox 的链接将显示在浏览器的侧面板中,而不是显示在主屏幕中。 我个人觉得这很烦人,正在寻找更好的解决方案。 当然可以手动编辑书签以使其不显示在侧面板中,但这需要额外的步骤。 我只是希望能够让人们以简单的方式为页面添加书签(该页面在 URL 中有大量 GET 信息,用于构建特定方案)。
恐怕 Firefox 根本不可能在主屏幕上显示该页面(因为谷歌搜索这个主题几乎没有什么值得使用的结果),但我可能错过了一些东西。 如果有人知道这是否可行,或者是否有解决方法,我很想听听。
I'm using the following JavaScript code:
<script language="JavaScript1.2" type="text/javascript">
function CreateBookmarkLink(title, url) {
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
} else if( window.external ) {
window.external.AddFavorite( url, title); }
else if(window.opera && window.print) {
return true; }
}
</script>
This will create a bookmark for Firefox and IE. But the link for Firefox will show up in the sidepanel of the browser, instead of being displayed in the main screen. I personally find this very annoying and am looking for a better solution. It is of course possible to edit the bookmark manually to have it not show up in the side panel, but that requires extra steps. I just want to be able to have people bookmark a page (that has a lot of GET information in the URL which is used to build a certain scheme) the easy way.
I'm afraid that it might not be possible to have Firefox present the page in the main screen at all (as Googling this subject resulted in practically nothing worth using), but I might have missed something. If anyone has an idea if this is possible, or if there's a workaround, I'd love to hear about it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于 Firefox,不需要通过脚本为页面书签设置任何 JavaScript,只有带有 title 和 rel="sidebar" 的锚标记可以执行此功能
我已经测试过在 FF9 上并且运行良好。
当您点击该链接时,Firefox 将打开一个对话框新建书签,如果您不希望在侧边栏上加载此书签,请取消选中在侧边栏中加载此书签 > 从对话框。
For Firefox no need to set any JavaScript for the bookmark an page by script, only an anchor tag with title and rel="sidebar" can do this functionality
I have tested it on FF9 and its working fine.
When you click on the link, Firefox will open an dialog box New Bookmark and if you wish to not load this bookmark on side bar then un-check Load this bookmark in the sidebar from dialog box.
我认为这是 Firefox 的唯一解决方案...我有一个更好的功能来执行该操作,它甚至适用于 Opera,并为其他“不支持”的浏览器显示一条消息。
I think that's the only solution for Firefox... I have a better function for that action, it works even for Opera and shows a message for other "unsupported" browsers.
您有一个特殊情况,
然后有一个“else”分支 - Firefox 不会落在第一个分支中,因此只添加面板吗?
You have a special case for
and then a branch for 'else' - wouldn't firefox land in the first branch and hence only add the panel?
Hojou,
看来这是为 Firefox 添加书签的唯一方法。 所以 FF 需要登陆第一个分支才能发生任何事情。 我在谷歌上搜索了更多,但我真的意识到这不可能在 FF 中正确解决......
Hojou,
It seems that is the only way to add a bookmark for Firefox. So FF needs to land in the first branch to have anything happening at all. I Googled some more but I'm really getting the idea this is impossible to properly address in FF...