<!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" >
<HTML>
<head>
<title>右侧随滚动条浮动广告</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<!--浮动广告代码开始-->
<div id="divMenu" style="position: absolute; visibility:visible; left:814px; top:0px; width:200px; ">
<table height="400" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td><iframe src="images/ad.htm" frameborder="0" width="180"
height="470" allowtransparency="allowTransparency"></iframe></td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript">
<!--
function moveRightEdge()
{
var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
yMenuFrom = parseInt (document.getElementById('divMenu').style.top, 0);
yMenuTo = document.body.scrollTop + 40;
timeoutNextCheck = 500;
if (yMenuFrom != yMenuTo)
{
yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
if (yMenuTo < yMenuFrom)
{yOffset = -yOffset;}
document.getElementById('divMenu').style.top = parseInt (document.getElementById('divMenu').style.top, 0) + yOffset;
timeoutNextCheck = 10;
}
setTimeout ("moveRightEdge()", timeoutNextCheck);
}
document.getElementById('divMenu').style.top = document.body.scrollTop + 200;
document.getElementById('divMenu').style.visibility = "visible";
moveRightEdge();
//-->
</script>
<!--浮动广告代码结束-->
<div style="height:2000px;"></div>
</body>
</html>
-----------------------
上面这段代码,把<!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" >
删除就正常,请问怎么回事?在firefox里面看,提示top有问题。搞不懂
将前两行删除就正常 说明楼主写的代码不规范 比如你这里有大写的标签,这是不对的 建议楼主去http://validator.w3.org/#validate_by_input这个页面验证一下代码
代码不符号你定义的标准。有时候用网上搜来的特效等。也遇到过同样的问题。把JS,CSS块再重构一遍。
那是当然firefox和ie不兼容,你可以判断一下浏览器,然后执行
<%if (Request.Browser.Browser.Equals("IE"))
{%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<% }%>
你给top设置属性的时候需要指定单位。
例如:
你的代码:
document.getElementById('divMenu').style.top = document.body.scrollTop + 200;
应该修改为:
document.getElementById('divMenu').style.top = document.body.scrollTop + 200 + "px";