Universal add to bookmarks script?

后端 未结 5 1350
情书的邮戳
情书的邮戳 2020-12-20 02:09

Does anyone know of a script that I can use to automatically add a site to favourites upon clicking of a link for multiple browsers? Atleast Firefox, IE, Chrome would be goo

相关标签:
5条回答
  • 2020-12-20 02:32

    A universal script for adding to bookmarks doesn't exists, because not all browsers expose an API for creating bookmarks. Generally, only IE exposes a direct API for this. Both Opera and Firefox offer a possibility to add a site to bookmarks that will be opened in the sidebar and that is a huge difference. Safari and Chrome also don't expose any API for this task.

    Some more info on this topic

    0 讨论(0)
  • 2020-12-20 02:40

    You can check out this jquery plugin if you are using that or just look at their source if you want to use your own. Though he mentions on his compatibility that Safari and Chrome do not expose this functionality in their API.

    http://www.dummwiam.com/jFav

    0 讨论(0)
  • 2020-12-20 02:44

    See digitalinspiration.

    1st Google result for javascript bookmark.

    0 讨论(0)
  • 2020-12-20 02:45

    In internet explorer it works with:

    window.external.AddFavorite(document.location,document.title);

    in firefox and in opera with:

    <a href="your_link_here" rel="sidebar" title="website page title here">Some link name</a>
    

    I haven't found a solution for safari / chrome yet.

    0 讨论(0)
  • 2020-12-20 02:56

    I use a small script to attempt adding a bookmark using the most popular window methods, until all have failed. Then it just prompts the user to manually add their bookmark...

    Like others have said (above) some browsers prohibit script-activated bookmarking, and because of security they want only users to add bookmarks.

    It is not perfect, but it is simple and works well.

    function addBookmark()
    {
        var success=false;
    
        // try each until all fail...
        try {
            window.external.AddFavorite(window.location, document.title);
            success=true;
       } catch(e) {}
    
        try {
            window.sidebar.addPanel(document.title,location.href,'');
            success=true;
        } catch(e) {}
    
        if(!success)
        {
            alert("AUTO BOOKMKARING not supported\r\nIn your current browser.\r\n\r\nPress CTRL+D, or CMD+D\r\nto manually bookmark this page.");
        }
    }
    
    0 讨论(0)
提交回复
热议问题