html
head
对联广告
-="-Type"=";=GBK"
bodystyle="margin:0px;"
divalign="center"
center
tableborder="1"width="776"height="3000"cellspacing="0"cellpadding="0"
tr
tdwidth="100%"valign="top"divalign="center"页面区域/div/td
/tr
/table
/center
/div
SCRIPTLANGUAGE="JavaScript"
!--
varshowad=true;
varToppx=60;//上端位置
varAdDivW=100;//宽度
varAdDivH=360;//高度
varPageWidth=800;//这个参数决定是否出现左右滚动条
varMinScreenW=1024;//显示广告的最小屏幕宽度象素
varClosebuttonHtml='divalign="right"style="position:absolute;top:0px;right:0px;margin:2px;padding:2px;z-index:2000;"ahref="javascript:;"οnclick="hidead()"style="color:red;text-decoration:none;font-size:12px;"关闭/a/div'
varAdContentHtml='divalign="center"brbr广br告br内br容/div
document.write('divid="Javascript.LeftDiv"style="position:absolute;border:1pxsolid#336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;"'+ClosebuttonHtml+'div'+AdContentHtml+'/div/div
document.write('divid="Javascript.RightDiv"style="position:absolute;border:1pxsolid#336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;"'+ClosebuttonHtml+'div'+AdContentHtml+'/div/div
functionscall(){
if(!showad){return;}
if(window.screen.widthMinScreenW){
alert("临时提示:
显示器分辨率宽度小于"+MinScreenW+",不显示广告");
showad=false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
return;
}
varBorderpx=((window.screen.width-PageWidth)/2-AdDivW)/2;
document.getElementById("Javascript.LeftDiv").style.display="";
document.getElementById("Javascript.LeftDiv").style.top=document.body.scrollTop+Toppx;
document.getElementById("Javascript.LeftDiv").style.left=document.body.scrollLeft+Borderpx;
document.getElementById("Javascript.RightDiv").style.display="";
document.getElementById("Javascript.RightDiv").style.top=document.body.scrollTop+Toppx;
document.getElementById("Javascript.RightDiv").style.left=document.body.scrollLeft+document.body.clientWidth-document.getElementById("Javascript.RightDiv").offsetWidth-Borderpx;
}
functionhidead()
{
showad=false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
}
window.οnscrοll=scall;
window.οnresize=scall;
window.οnlοad=scall;
//--
/SCRIPT
/body
/html
希望本文所述对大家的JavaScript程序设计有所帮助。