- 贴心猫(Imcat)
- 贴心代码
- 详情
scrollTop()
发布:2013-02-07 11:20
点击626次
评论:0条
[!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"]
[html xmlns="http://www.w3.org/1999/xhtml"]
[head]
[/head]
[body]
[table border="" style="margin:auto"]
[tr]
[td id="img"] [/td]
[/tr]
[/table]
[script type="text/javascript"]
function initImage(){
var key = ''url'';
var url = (new RegExp("([^(&|\?)]*)" + key + "=([^(&|#)]*)").test(location.href+"#")) ? RegExp.$2 : null;
var html = "[img src=''"+url+"'' /]";
document.getElementById(''img'').innerHTML = html;
}
initImage();
function xscrollTop() {
//前边是获取chrome等一般浏览器 如果获取不到就是ie了 就用ie的办法获取
var x=document.body.scrollTop||document.documentElement.scrollTop;
/*var timer=setInterval(function(){
x=x-100;
if(x[100){
x=0;
window.scrollTo(x,x);
clearInterval(timer);
}
window.scrollTo(x,x);
},"50");*/
window.scrollTo(0,0);
}
[/script]
[div style="height:500px"][/div]
[a onclick="xscrollTop()"]XXXX1[/a]
[div style="height:500px"][/div]
[a onclick="xscrollTop()"]XXXX2[/a]
[div style="height:500px"][/div]
[/body]
[/html]