首页 > 代码库 > JS积累
JS积累
1. <a>标签"加入收藏",兼容IE,FireFox等
function bookmarksite() { if (window.sidebar) { // Mozilla Firefox Bookmark window.sidebar.addPanel(document.title, window.location.href, ‘‘); } else if (window.external && (‘AddFavorite‘ in window.external)) { // IE Favorite window.external.AddFavorite(location.href, document.title); } else if (window.opera && window.print) { // Opera Hotlist this.title = document.title; return true; } else { // webkit - safari/chrome alert(‘Press ‘ + (navigator.userAgent.toLowerCase().indexOf(‘mac‘) != -1 ? ‘Command/Cmd‘ : ‘CTRL‘) + ‘ + D to bookmark this page.‘); } } //加入收藏 function bookmarksite(title, url) { if (window.sidebar) // firefox window.sidebar.addPanel(title, url, ""); else if (window.opera && window.print) { // opera var elem = document.createElement(‘a‘); elem.setAttribute(‘href‘, url); elem.setAttribute(‘title‘, title); elem.setAttribute(‘rel‘, ‘sidebar‘); elem.click(); } else if (document.all)// ie window.external.AddFavorite(url, title); }
JS积累
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。