固定在浏览器右下角的div,适合做广告位,兼容各浏览器
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>使用CSS将Div固定在窗口的右下角</title> <style> #INDEXT_RB_AD{ clear:both; width:200px; height:100px; z-index:1000; overflow:hidden; border:1px #ccc solid; bottom:5px; right:5px; /* 火狐、Google浏览器只需要后面这一句代码即可 */ position:fixed !important; /* 以下代码是针对IE6的 */ _position:absolute; _top: expression( eval( document.documentElement.scrollTop + document.documentElement.clientHeight - this.offsetHeight - (parseInt(this.currentStyle.marginTop,10)||0) - (parseInt(this.currentStyle.marginBottom,10)||0) ) - (parseInt(this.currentStyle.bottom,10)||0) ); } </style> </head> <body> <div style="height:2000px;">使用CSS将Div固定在窗口的右下角</div> <div id="INDEXT_RB_AD" style="display:;"> <div align="right" style=" width:100%; height:25px; line-height:25px; cursor:pointer; " onclick="document.getElementById('INDEXT_RB_AD').style.display = 'none';">关闭</div> <div>这里是您要显示的内容</div> </div> </body> </html> ======================================================================= 如果要将该功能写入js文件里,供网站多个页面同时调用,可以使用下列代码 ======================================================================= <script> //var RB_FLOAT_AD = "no"; //在不需要显示的页面加上此行代码 if ( typeof(RB_FLOAT_AD) == "undefined" || RB_FLOAT_AD != "no" ){ //输出CSS样式 document.write('<style>#INDEXT_RB_AD{ clear:both; width:200px; height:100px; z-index:1000; overflow:hidden; border:1px #ccc solid; bottom:10px; right:5px; /* 火狐、Google浏览器只需要后面这一句代码即可 */ position:fixed !important; /* 以下代码是针对IE6的 */ _position:absolute; _top: expression( eval( document.documentElement.scrollTop + document.documentElement.clientHeight - this.offsetHeight - (parseInt(this.currentStyle.marginTop,10)||0) - (parseInt(this.currentStyle.marginBottom,10)||0) ) - (parseInt(this.currentStyle.bottom,10)||0) ); }</style>'); // document.write('<div id="INDEXT_RB_AD" style="display:;"><div align="right" style=" width:100%; height:25px; line-height:25px; cursor:pointer;" onclick="document.getElementById('INDEXT_RB_AD').style.display = 'none';">关闭</div><div>这里是您要显示的内容</div></div>'); } </script>