最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

添加到收藏夹代码(兼容几乎所有的浏览器)_典型特效

来源:动视网 责编:小采 时间:2020-11-27 20:34:17
文档

添加到收藏夹代码(兼容几乎所有的浏览器)_典型特效

添加到收藏夹代码(兼容几乎所有的浏览器)_典型特效:兼容IE5+/Win, Firefox, Netscape 6+, Opera 7+, Safari, Konqueror 3, IE5/Mac, 还有 iCab 3. 代码如下:http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
推荐度:
导读添加到收藏夹代码(兼容几乎所有的浏览器)_典型特效:兼容IE5+/Win, Firefox, Netscape 6+, Opera 7+, Safari, Konqueror 3, IE5/Mac, 还有 iCab 3. 代码如下:http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd


兼容IE5+/Win, Firefox, Netscape 6+, Opera 7+, Safari, Konqueror 3, IE5/Mac, 还有 iCab 3.
代码如下:
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


addbookmark cross all browser - http://www.never-online.net







// /*
* Copyright 2006 Dynamic Site Solutions.
* Free use of this script is permitted for non-commercial applications,
* subject to the requirement that this comment block be kept and not be
* altered. The data and executable parts of the script may be changed
* as needed. Dynamic Site Solutions makes no warranty regarding fitness
* of use or correct function of the script. Terms for use of this script
* in commercial applications may be negotiated; for this, or for other
* questions, contact "license-info@dynamicsitesolutions.com".
*
* Script by: Dynamic Site Solutions -- http://www.dynamicsitesolutions.com/
* Last Updated: 2006-08-03
*/

//IE5+/Win, Firefox, Netscape 6+, Opera 7+, Safari, Konqueror 3, IE5/Mac, iCab 3

var addBookmarkObj = {
init:function() {
if(!document.getElementById || !document.createTextNode) return;
var cont=document.getElementById('addBookmarkContainer');
if(!cont) return;
var a=document.createElement('a');
a.href=location.href;
if(!window.opera) { // this doesn't work in Opera 7+ if the link has an
// onclick handler, so we only add it if the browser isn't Opera.
a.onclick=function() {
addBookmarkObj.exec(this.href,this.title);
return false;
}
}
a.rel='sidebar'; // this makes it work in Firefox and Opera 7+
a.title=document.title;
a=cont.appendChild(a);
a.appendChild(document.createTextNode('Bookmark This Page'));
},
exec:function(url, title) {
var isKonq=(isLikelyKonqueror3 && isLikelyKonqueror3());
var isMac=(navigator.userAgent.toLowerCase().indexOf('mac')!=-1);
var buttonStr = isMac?'Command/Cmd':'CTRL';

if(window.external && (!document.createTextNode ||
(typeof(window.external.AddFavorite)=='unknown'))) {
// IE4/Win generates an error when you
// execute "typeof(window.external.AddFavorite)"
// In IE7 the page must be from web server, not directly from a local
// file system, otherwise, you get a permission denied error.
window.external.AddFavorite(url, title); // IE/Win
} else if(isKonq) {
alert('You need to press CTRL + B to bookmark our site.');
} else if((window.sidebar &&
(navigator.userAgent.toLowerCase().indexOf('firefox')!=-1)) ||
(window.opera && opera.buildNumber && !isNaN(opera.buildNumber()))) {
void(0); // do nothing here (Firefox or Opera 7+)
} else if(window.opera) { // older Opera
alert('You need to press '+buttonStr+' + T to bookmark our site.');
} else if(window.home) { // Netscape, iCab
alert('You need to press '+buttonStr+' + D to bookmark our site.');
} else if(!window.print || isMac) { // IE5/Mac and Safari 1.0
alert('You need to press Command/Cmd + D to bookmark our site.');
} else {
alert('In order to bookmark this site you need to do so manually '+
'through your browser.');
}
}
}

function isLikelyKonqueror3() {
if(!document.getElementById) return false;
if(document.defaultCharset || window.opera || !window.print) return false;
if(window.home) return false; /* Konqueror doesn't support this but Firefox,
which has silent support for document.all when in Quirks Mode does */
if(document.all) return true; // Konqueror versions before 3.4
var likely = 1;
// testing for silent document.all support; try-catch used to keep it from
// generating errors in other browsers.
// try-catch causes errors in IE4 so we use the eval() to hide it.
// try {
// var str=document.all[0].tagName;
// } catch(err) { likely=0; }
eval("try{var str=document.all[0].tagName;}catch(err){likely=0;}");
return likely;
}

function dss_addEvent(el,etype,fn) {
if(el.addEventListener && (!window.opera || opera.version) &&
(etype!='load')) {
el.addEventListener(etype,fn,false);
} else if(el.attachEvent) {
el.attachEvent('on'+etype,fn);
} else {
if(typeof(fn) != "function") return;
var tempFunc = el['on'+etype];
el['on'+etype] = function() {
if(typeof(tempFunc) == "function") tempFunc();
fn();
}
}
}

dss_addEvent(window,'load',addBookmarkObj.init);
//]]>



cross-browser addBookmark

by www.dynamicsitesolutions.com



demonstration





collected by http://www.never-online.net

文档

添加到收藏夹代码(兼容几乎所有的浏览器)_典型特效

添加到收藏夹代码(兼容几乎所有的浏览器)_典型特效:兼容IE5+/Win, Firefox, Netscape 6+, Opera 7+, Safari, Konqueror 3, IE5/Mac, 还有 iCab 3. 代码如下:http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
推荐度:
标签: 浏览器 代码 兼容
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top