Firefox javascript 书签问题

发布于 2024-07-05 22:41:49 字数 711 浏览 7 评论 0原文

我正在使用以下 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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夜光 2024-07-12 22:41:49

对于 Firefox,不需要通过脚本为页面书签设置任何 JavaScript,只有带有 titlerel="sidebar" 的锚标记可以执行此功能

<a href="http://www.google.com" title="Google" rel="sidebar">Bookmark This Page</a>

我已经测试过在 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

<a href="http://www.google.com" title="Google" rel="sidebar">Bookmark This Page</a>

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.

落墨 2024-07-12 22:41:49

我认为这是 Firefox 的唯一解决方案...我有一个更好的功能来执行该操作,它甚至适用于 Opera,并为其他“不支持”的浏览器显示一条消息。

<script type="text/javascript">
function addBookmark(url,name){
    if(window.sidebar && window.sidebar.addPanel) {
        window.sidebar.addPanel(name,url,''); //obsolete from FF 23.
} else if(window.opera && window.print) { 
        var e=document.createElement('a');
        e.setAttribute('href',url);
        e.setAttribute('title',name);
        e.setAttribute('rel','sidebar');
        e.click();
} else if(window.external) {
        try {
            window.external.AddFavorite(url,name);
        }
        catch(e){}
}
else
        alert("To add our website to your bookmarks use CTRL+D on Windows and Linux and Command+D on the Mac.");
}
</script>

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.

<script type="text/javascript">
function addBookmark(url,name){
    if(window.sidebar && window.sidebar.addPanel) {
        window.sidebar.addPanel(name,url,''); //obsolete from FF 23.
} else if(window.opera && window.print) { 
        var e=document.createElement('a');
        e.setAttribute('href',url);
        e.setAttribute('title',name);
        e.setAttribute('rel','sidebar');
        e.click();
} else if(window.external) {
        try {
            window.external.AddFavorite(url,name);
        }
        catch(e){}
}
else
        alert("To add our website to your bookmarks use CTRL+D on Windows and Linux and Command+D on the Mac.");
}
</script>
北恋 2024-07-12 22:41:49

您有一个特殊情况,

if (window.sidebar) 

然后有一个“else”分支 - Firefox 不会落在第一个分支中,因此只添加面板吗?

You have a special case for

if (window.sidebar) 

and then a branch for 'else' - wouldn't firefox land in the first branch and hence only add the panel?

甜扑 2024-07-12 22:41:49

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文