关于固定网页上的一个div
比如gmail载入的时候显示的:loading字样是固定在窗口的右上角的,这个该怎么实现?
我参照网上的资料写的:
var loading = document.getElementbyId( "loading ");
function moving()
{
var x = 600;//浮动广告层固定于浏览器的x方向位置
var y = 300;//浮动广告层固定于浏览器的y方向位置
var diff = (document.body.scrollTop + y - loading.style.top)*.40;
var y = document.body.scrollTop + y - diff;
loading.style.top = y;
loading.style.left = x;
setTimeout( "moving() ",10);
}
moving();
可是发现根本不起作用啊..希望有人帮忙看看是什么问题
PS:需要在FireFox下也能正常运行哦
------解决方案--------------------楼主上面的代码 getElementbyId 写错了 By 大写
function moving()
{
var loading = document.getElementById( "divDivision ");
var x = 600;//浮动广告层固定于浏览器的x方向位置
var y = 300;//浮动广告层固定于浏览器的y方向位置
var diff = (document.body.scrollTop + y - loading.style.top)*.40;
var y = document.body.scrollTop + y - diff;
loading.style.position = 'absolute ';
loading.style.top = y;
loading.style.left = x;
}
setTimeout( "moving() ",1000);
------解决方案-------------------- <body onscroll= "moving() ">
.....
function moving()
{
var loading = document.getElementById( "divDivision ");
loading.style.posTop = document.body.scrollTop;
loading.style.posLeft = document.body.scrollLeft;
}
ie测试没有问题啊
------解决方案--------------------function moving()
{
var loading = document.getElementById( "divDivision ");
var x = 600;//浮动广告层固定于浏览器的x方向位置
var y = 300;//浮动广告层固定于浏览器的y方向位置
var diff = (document.body.scrollTop + y - loading.style.top)*.40;
var y = document.body.scrollTop + y - diff;
loading.style.position = 'absolute ';
loading.style.top = y;
loading.style.left = x;
}
setTimeout( "moving() ",10);
这样IE ff 都通过了~