How to add to Favorites/Bookmark for all browser in javascript [duplicate]

别说谁变了你拦得住时间么 提交于 2019-12-04 18:12:22
Dimitri Reifschneider

Due to security reasons it is not possible to add a bookmark in Google Chrome using Javascript.

Alternatively, you could output a message for using the shortcut:

    $('#bookmarkme').click(function(){
        alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != - 1 ? 'Command/Cmd' : 'CTRL') + ' + D to bookmark this page.');
    }); 

Since window.sidebar.addPanel is deprecated and not a standard implementation (https://developer.mozilla.org/en-US/docs/Web/APIWwindow.sidebar), you may use the API to add bookmarks when creating an add-on (https://developer.mozilla.org/en-US/docs/Code_snippets/Bookmarks).

Nevertheless it should not be a high burden for users to add their favorite website as bookmark inside the browser.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!