例1,js对联广告代码。
例2,js对联广告代码。
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>js对联广告代码</title>
<script language="javascript" type="text/javascript">
<!--对联代码开始-->
//<![cdata[
var adleftsrc = ""//图片地址
var adleftflash = "flash"
var adlefthref = ""
var adleftwidth = 85
var adleftheight = 255
var adrightsrc = ""//图片地址
var adrightflash = ""
var adrighthref = ""
var adrightwidth = 85
var adrightheight = 255
var margintop = 200 //在这里更改距离浏览器底端的高度
var marginleft = 15//在这里更改距离浏览器右端的高度
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 (adleftsrc != "") {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) - adleftheight - margintop + 'px';}
if (adrightsrc != "") {
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) - adrightheight - margintop + 'px';
document.getelementbyid("adrightfloat").style.left = ((document.body.clientwidth > document.documentelement.clientwidth)?document.body.clientwidth:document.documentelement.clientwidth) - adrightwidth - marginleft + 'px';
}
}
else{
if (adleftsrc != "") {document.getelementbyid("adleftfloat").style.top = (document.body.scrolltop?document.body.scrolltop:document.documentelement.scrolltop) + ((document.documentelement.clientheight == 0)?document.body.clientheight:document.documentelement.clientheight) - adleftheight - margintop + 'px';}
if (adrightsrc != "") {
document.getelementbyid("adrightfloat").style.top = (document.body.scrolltop?document.body.scrolltop:document.documentelement.scrolltop) + ((document.documentelement.clientheight == 0)?document.body.clientheight:document.documentelement.clientheight) - adrightheight - margintop + 'px';
document.getelementbyid("adrightfloat").style.left = ((document.documentelement.clientwidth == 0)?document.body.clientwidth:document.documentelement.clientwidth) - adrightwidth - marginleft + 'px';
}
}
if (adleftsrc != "") {document.getelementbyid("adleftfloat").style.left = marginleft + 'px';}
}
if (adleftsrc != "") {
if (adleftflash == "flash") {
document.write("<div id="adleftfloat" style="position: absolute;width:" + adleftwidth + ";height:100px; font-size:12px;"><img src="images/close.gif" width="12" border="0" height="12" onmousedown="javascript:close_float_left();void(0);";>");
document.write("<div id="float" style="width:" + adleftwidth + ";"><embed src="" + adleftsrc + "" quality="high" width="" + adleftwidth + "" height="" + adleftheight + "" type="application/x-shockwave-flash"></embed></div>");
document.write("</div>");
}
else{
document.write("<div id="adleftfloat" style="position: absolute;width:" + adleftwidth + ";height:100px; font-size:12px;"><img src="images/close.gif" width="12" border="0" height="12" onmousedown="javascript:close_float_left();void(0);";>");
document.write("<div id="float" style="width:" + adleftwidth + ";"><a href="" + adlefthref +"" target=_blank><img src="" + adleftsrc + "" width="" + adleftwidth + "" height="" + adleftheight + "" border="0" ></a></div>");
document.write("</div>");
}
}
if (adrightsrc != "") {
if (adrightflash == "flash") {
document.write("<div id="adrightfloat" style="position: absolute;width:" + adrightwidth + ";height:100px; font-size:12px;text-align:right;"><img src="images/close.gif" width="12" border="0" height="12" onmousedown="javascript:close_float_right();void(0);";>");
document.write("<div id="float" style="width:" + adrightwidth + ";"><embed src="" + adrightsrc + "" quality="high" width="" + adleftwidth + "" height="" + adrightheight + "" type="application/x-shockwave-flash"></embed></div>");
document.write("</div>");
}
else{
document.write("<div id="adrightfloat" style="position: absolute;width:" + adrightwidth + ";height:100px; font-size:12px;text-align:right;"><img src="images/close.gif" width="12" border="0" height="12" onmousedown="javascript:close_float_right();void(0);";>");
document.write("<div id="float" style="width:" + adrightwidth + ";"><a href="" + adrighthref +"" target=_blank><img src="" + adrightsrc + ""width="" + adleftwidth + "" height="" + adrightheight + "" border="0" ></a></div>");
document.write("</div>");
}
}
load();
function close_float_right(){
document.getelementbyid("adrightfloat").style.display="block";}
function close_float_left(){
document.getelementbyid("adleftfloat").style.display="block";} //]]>
<!--对联代码结束-->
</script>
</head>
<body>
</body>
</html>