`

网页浮动窗口代码

阅读更多
引用
以下代码存为网页直接运行(注:如果网页有其他代码的话,此代码最好放在网页最后也就是"</body>"标签之前就是了。。)

<html>
<head>

</head>
<body>
<DIV id=ad_dl01 
style="Z-INDEX: 1; LEFT: 5px; VISIBILITY: visible; WIDTH: 100px; POSITION: absolute; TOP: 

95px">
<TABLE cellSpacing=0 cellPadding=0 width=100 border=0>
  <TBODY>
  <TR>
    <TD align=left><A onclick="ad_dl01.style.visibility='hidden'"><IMG 
      height=16 src="/oblog/images/yanglan_01.gif" width=100 border=0></A></TD></TR>
  <TR>
    <TD><A href="/oblog/" 
      target=_blank><IMG height=184 src="/oblog/images/fudongleft.gif" width=100 
      border=0></A></TD></TR></TBODY></TABLE></DIV>
<DIV id=ad_dl02 
style="Z-INDEX: 1; RIGHT: 5px; VISIBILITY: visible; WIDTH: 100px; POSITION: absolute; TOP: 

95px">
<TABLE cellSpacing=0 cellPadding=0 width=100 border=0>
  <TBODY>
  <TR>
    <TD align=right><A onclick="ad_dl02.style.visibility='hidden'"><IMG 
      height=16 src="/oblog/images/yanglan_01.gif" width=100 border=0></A></TD></TR>
  <TR>
    <TD><A href="/oblog/" 
      target=_blank><IMG height=184 src="/oblog/images/fudongright.gif" 
      width=100 border=0></A></TD></TR></TBODY></TABLE></DIV>
<SCRIPT type=text/javascript>
var step_ratio = 0.1;
objs = new Array();
objs_x = new Array();
objs_y = new Array();
function addfollowmark(name, x, y) {
  i = objs.length;
  objs[i] = document.getElementById(name);
  objs_x[i] = x;
  objs_y[i] = y;
}
function followmark() {
  for(var i=0; i<objs.length; i++) {
    var fm = objs[i];
    var fm_x = typeof(objs_x[i]) == 'string' ? eval(objs_x[i]) : objs_x[i];
    var fm_y = typeof(objs_y[i]) == 'string' ? eval(objs_y[i]) : objs_y[i];
    if (fm.offsetLeft != document.body.scrollLeft + fm_x) {
      var dx = (document.body.scrollLeft + fm_x - fm.offsetLeft) * step_ratio;
      dx = (dx > 0 ? 1 : -1) * Math.ceil(Math.abs(dx));
      fm.style.left = fm.offsetLeft + dx;
    }
 var diffY;
 if (document.documentElement && document.documentElement.scrollTop)
 diffY = document.documentElement.scrollTop;
else if (document.body)
 diffY = document.body.scrollTop;
 
    if (fm.offsetTop != diffY  + fm_y) {
      var dy = (diffY  + fm_y - fm.offsetTop) * step_ratio;
      dy = (dy > 0 ? 1 : -1) * Math.ceil(Math.abs(dy));
      fm.style.top = fm.offsetTop + dy;
    }
    fm.style.display = '';
  }
}
addfollowmark("ad_dl01", 5, 180);
addfollowmark("ad_dl02", "document.body.clientWidth-105", 180);
setInterval('followmark()',20);
</SCRIPT>
</body>

</html>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics