当前位置:首页 » 网站技术 » HTML & CSS

上下浮动广告代码 不兼容xhtml

...

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>智思网 http://www.zhisi.net 欢迎您!</title>
</head>

<body>
<div style="height:1000px;"></div>
<script language="JavaScript">
<!--
var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isNS = navigator.appName == "Netscape";

function getRef(id) {
 if (isDOM) return document.getElementById(id);
 if (isIE4) return document.all[id];
 if (isNS4) return document.layers[id];
}
function moveRightEdge() {
 var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
 if (isDOM) {
  yMenuFrom   = parseInt (divFloat.style.top, 0);
  yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop) + 150;
 }
 timeoutNextCheck = 500;
 if (yMenuFrom != yMenuTo) {
  yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
  if (yMenuTo < yMenuFrom)
   yOffset = -yOffset;
  if (isNS4)
   divFloat.top += yOffset;
  else if (isDOM)
   divFloat.style.top = parseInt (divFloat.style.top, 0) + yOffset;
   timeoutNextCheck = 10;
 }
 setTimeout ('moveRightEdge()', timeoutNextCheck);  
}
//-->
</script>
<style type="text/css">
#divFloat{Z-INDEX:20;POSITION:absolute;LEFT:303px;TOP:150px;WIDTH:250px;HEIGHT:200px;VISIBILITY:visible;background:#ccc;padding:20px;}
</style>
<div id="divFloat">
智思网 <br /><br /> http://www.zhisi.net <br /><br />欢迎您!
</div>
<script language="javascript">
<!--
if (isDOM) {
 var divFloat = getRef('divFloat');
  divFloat.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) + 190;
  divFloat.style.visibility = "visible";
  moveRightEdge();
}
//-->
</script>
</body>

继续阅读
浮动层代码兼容xhtml 测试可用
发表评论

昵称:
最新评论
暂时没有评论!