MediaWiki:Common.js:修订间差异
跳到导航
跳到搜索
小无编辑摘要 |
小无编辑摘要 |
||
| 第1行: | 第1行: | ||
/* 此处的JavaScript将加载于所有用户每一个页面。 */ | /* 此处的JavaScript将加载于所有用户每一个页面。 */ | ||
/* 在页面右边显示滑动按钮,点击跳到顶部/底部。 */ | /* 在页面右边显示滑动按钮,点击跳到顶部/底部。 */ | ||
var suspendcode="<DIV id=backi style=' | var suspendcode="<DIV id='backi' style='z-index:999;font-size:10px;'><a href='#top' title='顶部'>▲</a><br><a href='#bottom' title='底部' onClick='window.scrollTo(0,10000);'>▼</a></div>"; | ||
document.write(suspendcode); | document.write(suspendcode); | ||
function scrollx(p){ | |||
function | var d = document,dd = d.documentElement,db = d.body,w = window,o = d.getElementById(p.id),ie6 = /msie 6/i.test(navigator.userAgent),style,timer; | ||
if(o){ | |||
o.style.cssText +=";position:"+(p.f&&!ie6?'fixed':'absolute')+";"+(p.l==undefined?'right:0;':'left:'+p.l+'px;')+(p.t!=undefined?'top:'+p.t+'px':'bottom:0'); | |||
if( | if(p.f&&ie6){ | ||
else | o.style.cssText +=';left:expression(documentElement.scrollLeft + '+(p.l==undefined?dd.clientWidth-o.offsetWidth:p.l)+' + "px");top:expression(documentElement.scrollTop +'+(p.t==undefined?dd.clientHeight-o.offsetHeight:p.t)+'+ "px" );'; | ||
dd.style.cssText +=';background-image: url(about:blank);background-attachment:fixed;'; | |||
}else{ | |||
} | if(!p.f){ | ||
w.onresize = w.onscroll = function(){ | |||
clearInterval(timer); | |||
timer = setInterval(function(){ | |||
//双选择为了修复chrome 下xhtml解析时dd.scrollTop为 0 | |||
var st = (dd.scrollTop||db.scrollTop),c; | |||
c = st - o.offsetTop + (p.t!=undefined?p.t:(w.innerHeight||dd.clientHeight)-o.offsetHeight); | |||
if(c!=0){ | |||
o.style.top = o.offsetTop + Math.ceil(Math.abs(c)/10)*(c<0?-1:1) + 'px'; | |||
}else{ | |||
clearInterval(timer); | |||
} | |||
},10); | |||
} | |||
} | |||
} | |||
} | |||
}; | |||
scrollx({ | |||
id:'backi', | |||
l:5, | |||
t:200, | |||
f:1 | |||
}); | |||
/* | |||
id 你要滚动的内容的id | |||
l 横坐标的位置 不写为紧贴右边 | |||
t 你要放在页面的那个位置默认是贴着底边 0是贴着顶边 | |||
f 1表示固定 不写或者0表示滚动 | |||
*/ | |||
2012年8月15日 (三) 11:54的版本
/* 此处的JavaScript将加载于所有用户每一个页面。 */
/* 在页面右边显示滑动按钮,点击跳到顶部/底部。 */
var suspendcode="<DIV id='backi' style='z-index:999;font-size:10px;'><a href='#top' title='顶部'>▲</a><br><a href='#bottom' title='底部' onClick='window.scrollTo(0,10000);'>▼</a></div>";
document.write(suspendcode);
function scrollx(p){
var d = document,dd = d.documentElement,db = d.body,w = window,o = d.getElementById(p.id),ie6 = /msie 6/i.test(navigator.userAgent),style,timer;
if(o){
o.style.cssText +=";position:"+(p.f&&!ie6?'fixed':'absolute')+";"+(p.l==undefined?'right:0;':'left:'+p.l+'px;')+(p.t!=undefined?'top:'+p.t+'px':'bottom:0');
if(p.f&&ie6){
o.style.cssText +=';left:expression(documentElement.scrollLeft + '+(p.l==undefined?dd.clientWidth-o.offsetWidth:p.l)+' + "px");top:expression(documentElement.scrollTop +'+(p.t==undefined?dd.clientHeight-o.offsetHeight:p.t)+'+ "px" );';
dd.style.cssText +=';background-image: url(about:blank);background-attachment:fixed;';
}else{
if(!p.f){
w.onresize = w.onscroll = function(){
clearInterval(timer);
timer = setInterval(function(){
//双选择为了修复chrome 下xhtml解析时dd.scrollTop为 0
var st = (dd.scrollTop||db.scrollTop),c;
c = st - o.offsetTop + (p.t!=undefined?p.t:(w.innerHeight||dd.clientHeight)-o.offsetHeight);
if(c!=0){
o.style.top = o.offsetTop + Math.ceil(Math.abs(c)/10)*(c<0?-1:1) + 'px';
}else{
clearInterval(timer);
}
},10);
}
}
}
}
};
scrollx({
id:'backi',
l:5,
t:200,
f:1
});
/*
id 你要滚动的内容的id
l 横坐标的位置 不写为紧贴右边
t 你要放在页面的那个位置默认是贴着底边 0是贴着顶边
f 1表示固定 不写或者0表示滚动
*/