船长 发表于 2009-04-15 10:39 | 分类:javascript | 阅读数:474 次
js广告-左右底部广告,可定制左边显示、右边显示和两边显示,代码相当简单
<script type="text/javascript" language="javascript"> var MmyeeAdShow = 3; //1为左侧显示 2为右侧显示 其他为两侧显示 var MmyeeAdWidth =300; //广告宽度 var MmyeeAdHeight = 200; //广告高度 //左边浮动 var AdLeftContent= "<div><iframe id='iframyee' bordercolor='#000000' frameborder='0' hspace='0' marginheight='0' marginwidth='0' scrolling='no' src='http://www.songlecn.com' width='"+MmyeeAdWidth+"' height='"+MmyeeAdHeight+"'></iframe></div>"; //右边浮动 var AdRightContent = "<div><iframe id=iframyee frameborder=0 marginwidth=0 marginheight=0 bordercolor='#000000' hspace='0' scrolling=no src='http://www.songlecn.com' width='"+MmyeeAdWidth+"' height='"+MmyeeAdHeight+"'></iframe></div>" //漂浮据页面底部设定框值,为了美观请不要修改次参数 var marginTop = 10 //漂浮据边框的距离 var marginLeft = 5 var navUserAgent = navigator.userAgent function load() { judge(); move(); } function move() { judge(); setTimeout("move();",80) } function judge(){ if (navUserAgent.indexOf("Firefox") >= 0 || navUserAgent.indexOf("Opera") >= 0) { if (MmyeeAdShow != "2") { document.getElementById("adLeftFloat").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight) - (MmyeeAdHeight) - marginTop + 'px'; } if (MmyeeAdShow != "1") { document.getElementById("adRightFloat").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight) - (MmyeeAdHeight) - marginTop + 'px'; document.getElementById("adRightFloat").style.left = ((document.body.clientWidth > document.documentElement.clientWidth)?document.body.clientWidth:document.documentElement.clientWidth) - MmyeeAdWidth - marginLeft + 'px'; } } else{ if (MmyeeAdShow != "2") { document.getElementById("adLeftFloat").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.documentElement.clientHeight == 0)?document.body.clientHeight:document.documentElement.clientHeight) - (MmyeeAdHeight) - marginTop + 'px'; } if (MmyeeAdShow != "1") { document.getElementById("adRightFloat").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.documentElement.clientHeight == 0)?document.body.clientHeight:document.documentElement.clientHeight) - (MmyeeAdHeight) - marginTop + 'px'; document.getElementById("adRightFloat").style.left = ((document.documentElement.clientWidth == 0)?document.body.clientWidth:document.documentElement.clientWidth) - MmyeeAdWidth - marginLeft + 'px'; } } if (MmyeeAdShow != "2") { document.getElementById("adLeftFloat").style.left = marginLeft + 'px'; } } if (MmyeeAdShow != "2") { document.write("<div id=\"adLeftFloat\" style=\"position: absolute;width:" + MmyeeAdWidth + ";\"><table border=0 cellpadding=0 cellspacing=0><tr><td>"+AdLeftContent+"</td></tr></table></div>"); } if (MmyeeAdShow != "1") { document.write("<div id=\"adRightFloat\" style=\"position: absolute;width:" + MmyeeAdWidth + ";\"><table border=0 cellpadding=0 cellspacing=0><tr><td>"+AdRightContent+"</td></tr></table></div>"); } load(); </script>
提示:你可以先修改部分代码再运行。
您的网名: * 必填
电子邮件: * 绝不会泄露
个人主页:
评论内容:
(Ctrl+Enter快捷回复)
web集结号致力于