- var url = window.location.href;
- var title = window.document.title;
- var ua = navigator.userAgent.toLowerCase();
- if(ua.indexOf("msie 8") > -1){
- window.external.addToFavoritesBar(url,title);//IE8
- }else{
- try {
- window.external.addFavorite(url, title);
- } catch(e) {
- try {
- window.sidebar.addPanel(title, url, "");//firefox
- } catch(e) {
- alert("加入收藏失败,请使用Ctrl+D进行添加");
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/051220137768.html
来源: http://www.codesnippet.cn/detail/051220137768.html