文本滚动在firefox中不起作用(在IE浏览器中)。
标记+ javascript:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<script type="text/javascript" language="javascript">
var scrollspeed = "1";
var speedjump = "30";
var interval = "";
var current;
current = (scrollspeed);
function ScrollDiv() {
dataobj.style.top = parseInt(dataobj.style.top) - (scrollspeed);
if (parseInt(dataobj.style.top) < AreaHeight * (-1)) {
//restart
dataobj.style.top = "200px";
}
else {
}
}
function ScrollStart() {
dataobj = document.getElementById("NewsDiv");
dataobj.style.top = "2px";
AreaHeight = dataobj.offsetHeight;
interval = setInterval("ScrollDiv()", speedjump);
}
</script>
</head>
<body onmouseover="scrollspeed=0" onmouseout="scrollspeed=current" onload="ScrollStart();">
<div id="NewsDiv">
<table cellpadding="5" cellspacing="0" border="0" width="100%">
<tr>
<td>
<span class="title">Website News1<br /></span>
BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA
<br /><br />
<span class="title">Website News2<br /></span>
BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA
<br /><br />
<span class="title">Website News3<br></span>
BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA
<br /><br />
</td>
</tr>
</table>
</div>
</body>
CSS:
body
{
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
#NewsDiv
{
position: absolute;
left: 0px;
top: 0px;
width: 100%;
}
在线(如果仍然可用): http://www.webdevout.net/test?015&raw
答案 0 :(得分:1)
您需要将“px”添加到dataobj.style.top
的新值。
function ScrollDiv() {
dataobj.style.top = (parseInt(dataobj.style.top) - (scrollspeed)) + "px";
IE“错误地”假设它是像素值。 Firefox没有并且给你一个错误。
答案 1 :(得分:0)
HI
未在“top”声明中指定单位将导致Firefox出错;这正是你的问题所在。
更改此行:
dataobj.style.top = parseInt(dataobj.style.top) - (scrollspeed);
对此:
dataobj.style.top = parseInt(dataobj.style.top) - (scrollspeed)+“px”;
它会起作用。经过测试和测试致力于FF3.5