一:Demo
<div id="ShowAD" style="width: 131px; height: 301px; position:absolute;overflow: hidden;z-index:9999999999;background-color:#ffffff;">
<div style=" width:120px;height:270px;padding:4px;border:#acacac 1px solid;overflow:hidden;">
<a href=\'http://www.baidu.com\' target="_blank"><img src=\'333\' width="120" height="270"/></a></div>
<div style="left: 0px; width: 131px; height: 20px; text-align: center; color:#ffffff; line-height: 20px; font-family: 微软雅黑; font-size: 12px; position: absolute; cursor: pointer; background-color: rgb(153, 153, 153);" onClick="closead();">关闭</div>
<br>
</div>
<script type="text/javascript" language="javascript">
<%-- 右侧可关闭广告--%>
var bodyfrm = (document.compatMode.toLowerCase() == "css1compat") ? document.documentElement : document.body;
var adst = document.getElementById("ShowAD").style;
adst.top = (bodyfrm.clientHeight - 430 - 22) + "px";
adst.left = (bodyfrm.clientWidth - 165) + "px";
function moveR() {
adst.top = (bodyfrm.scrollTop + bodyfrm.clientHeight - 430 - 22) + "px";
adst.left = (bodyfrm.scrollLeft + bodyfrm.clientWidth - 165) + "px";
}
setInterval("moveR();", 80);
function closead() {
adst.display = \'none\';
}
</script>
二:与后台交互
1,div添加runat=\'server\'
<script type="text/javascript" language="javascript">
<%-- 右侧可关闭广告--%>
var bodyfrm = (document.compatMode.toLowerCase() == "css1compat") ? document.documentElement : document.body;
var divShowAD = $("[id$=ShowAD]");
divShowAD.css({ "top": (bodyfrm.clientHeight - 430 - 22) + "px", "left": (bodyfrm.clientWidth - 165) + "px"});
function moveR() {
divShowAD.css({ "top": (bodyfrm.scrollTop + bodyfrm.clientHeight - 430 - 22) + "px", "left": (bodyfrm.scrollLeft + bodyfrm.clientWidth - 165) + "px" });
}
setInterval("moveR();", 80);
function closead() {
divShowAD.css({ "display": "none" });
}
</script>