<div class="codetitle"> <span><a style="CURSOR: pointer" data="83761" class="copybut" id="copybut83761" onclick="doCopy('code83761')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code83761"> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br><html xmlns="http://www.w3.org/1999/xhtml"> <br><head> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <br><title>侧边栏广告</title> <br><style type="text/css"> <br>#show { width:100px; height:80px; background:#0f0; position:fixed; _position:absolute; right:0px; top:0px;} <br></style> <br><script type="text/javascript"> <br>window.onscroll = window.onresize = window.onload = function(){ <br><br>var oDiv = document.getElementById("show"); <br>var sTop = document.documentElement.scrollTop || document.body.scrollTop; <br>var cHeight= document.documentElement.clientHeight || document.body.clientHeight; <br>var mid = (cHeight - oDiv.offsetHeight) / 2; <br>// oDiv.style.top = parseInt(sTop mid) "px"; //理论上应该只设这句就可以居中吧 <br><br>//实际上的 各大浏览器只认识下面这if判断 <br>if(navigator.appVersion.indexOf("MSIE 6")> -1){ <br>oDiv.style.top = parseInt(sTop mid) "px"; <br>}else{ <br>oDiv.style.top =mid "px"; <br>} <br>} <br> </div>