这段脚本在Firefox(火狐)不兼容 请高手指点一二
<SCRIPT language=JavaScript>
<!--
var xPos = 20;
var yPos = document.body.clientHeight;
var step = 1;
var delay = 30;
var height = 0;
var Hoffset = 0;
var Woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
var interval;
img.style.top = yPos;
function changePos() {
width = document.getAttribute().body.clientWidth;
height = document.getAttribute().body.clientHeight;
Hoffset = img.offsetHeight;
Woffset = img.offsetWidth;
img.style.left = xPos + document.body.scrollLeft;
img.style.top = yPos + document.body.scrollTop;
if (yon) {
yPos = yPos + step;
}
else {
yPos = yPos - step;
}
if (yPos < 0) {
yon = 1;
yPos = 0;
}
if (yPos >= (height - Hoffset)) {
yon = 0;
yPos = (height - Hoffset);
}
if (xon) {
xPos = xPos + step;
}
else {
xPos = xPos - step;
}
if (xPos < 0) {
xon = 1;
xPos = 0;
}
if (xPos >= (width - Woffset)) {
xon = 0;
xPos = (width - Woffset);
}
}
function www_helpor_net() {
img.visibility = "visible";
interval = setInterval('changePos()', delay);
}
www_helpor_net();
//For more,visit:www.helpor.net
-->
</SCRIPT>
我要的是ie和火狐都好用 怎么办那?
是用:var yPos = document.documentElement.clientHeight;
尊敬的用户,您好!很高兴为您答疑。
鉴于您的描述,您的问题在于获取浏览器框体高度,推荐阅读:
javascript 获取 浏览器body高宽等 (兼容多个浏览器:IE Firefox google apple 测试通过)
希望我的回答对您有所帮助,如有疑问,欢迎继续咨询我们。
本回答被网友采纳