<script language="javascript" type="text/javascript">
<!-- // 对联广告代码开始
var showad = true;
var Toppx = 100; //上端位置
var AdDivW = 110; //宽度
var AdDivH = 6; //高度
var PageWidth = 800; //页面多少宽度象素下正好不出现左右滚动条
var MinScreenW = 1024; //显示广告的最小屏幕宽度象素 var ClosebuttonHtml = '<div align="right" style="position: absolute;top:0px;right:0px;margin:0px;padding:0px;z-index:2000;"><a href="javascript:;" onclick="hidead()" style="color:white;text-decoration:none;font-size:12px;">关闭</a></div>'
var AdContentHtml1 = '<img border="0" src="http://img.baidu.com/img/logo-zhidao.gif">'; //指定左侧的广告图片位置
var AdContentHtml2 = '<img border="0" src="http://img.baidu.com/img/logo-zhidao.gif">'; //指定右侧的广告图片位置
document.write ('<div id="Javascript.LeftDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ClosebuttonHtml+'<div>'+AdContentHtml1+'</div></div>');
document.write ('<div id="Javascript.RightDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ClosebuttonHtml+'<div>'+AdContentHtml2+'</div></div>');
window.onscroll=scall;
window.onresize=scall;
window.onload=scall;
function scall()
{
if(!showad){return;}
if (window.screen.width<MinScreenW)
{
alert("临时提示:\n\n显示器分辨率宽度小于"+MinScreenW+",不显示广告");
showad = false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
return;
}
var Borderpx = ((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;
} function hidead()
{
showad = false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
}
</script>
上面事一段对联广告的代码?我想把这一段代码包含在一个JS文件里面然后用一个Function调用他们
调用的时候 可以传入参数设置这个对联广告参数: 左边图片 ,右边图片,图片高,图片宽,离顶部的距离
<!-- // 对联广告代码开始
var showad = true;
var Toppx = 100; //上端位置
var AdDivW = 110; //宽度
var AdDivH = 6; //高度
var PageWidth = 800; //页面多少宽度象素下正好不出现左右滚动条
var MinScreenW = 1024; //显示广告的最小屏幕宽度象素 var ClosebuttonHtml = '<div align="right" style="position: absolute;top:0px;right:0px;margin:0px;padding:0px;z-index:2000;"><a href="javascript:;" onclick="hidead()" style="color:white;text-decoration:none;font-size:12px;">关闭</a></div>'
var AdContentHtml1 = '<img border="0" src="http://img.baidu.com/img/logo-zhidao.gif">'; //指定左侧的广告图片位置
var AdContentHtml2 = '<img border="0" src="http://img.baidu.com/img/logo-zhidao.gif">'; //指定右侧的广告图片位置
document.write ('<div id="Javascript.LeftDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ClosebuttonHtml+'<div>'+AdContentHtml1+'</div></div>');
document.write ('<div id="Javascript.RightDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ClosebuttonHtml+'<div>'+AdContentHtml2+'</div></div>');
window.onscroll=scall;
window.onresize=scall;
window.onload=scall;
function scall()
{
if(!showad){return;}
if (window.screen.width<MinScreenW)
{
alert("临时提示:\n\n显示器分辨率宽度小于"+MinScreenW+",不显示广告");
showad = false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
return;
}
var Borderpx = ((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;
} function hidead()
{
showad = false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
}
</script>
上面事一段对联广告的代码?我想把这一段代码包含在一个JS文件里面然后用一个Function调用他们
调用的时候 可以传入参数设置这个对联广告参数: 左边图片 ,右边图片,图片高,图片宽,离顶部的距离
解决方案 »
- 100分求~~档案管理系统 报价.100分
- 我想实现点击一下按钮就在gridview中添加一行一样的数据。
- Infragistics.WebUI.WebSchedule.WebDateChooser缺少程序集引用...
- 在上海,这样的程序员月收入如何?
- 购物车怎样设计,比较好?
- ConfigurationSettings.AppSettings.Add怎么用?
- 为什么现在很多SMPT账号用system.net.mail.mailmessage发不邮件?【新注册居然给不了分,晕,明天补上。】
- 如何控制datagrid的高度和列的高度呢?总体感觉datagrid不太美观,那位有好的办法?
- 关于新闻网站信息摘录的问题?
- 怎么给一个TextBox设置焦点?
- 寻找高手,月薪7500以上
- 一个很简单的问题
function setshowad(leftpic,rightpic,AdW,AdH,AdTop)
{
var showad = true;
var Toppx = AdTop; //上端位置
var AdDivW = leftpic; //宽度
var AdDivH = rightpic; //高度
var PageWidth = 800; //页面多少宽度象素下正好不出现左右滚动条
var MinScreenW = 1024; //显示广告的最小屏幕宽度象素 var ClosebuttonHtml = ' <div align="right" style="position: absolute;top:0px;right:0px;margin:0px;padding:0px;z-index:2000;"> <a href="javascript:;" onclick="hidead()" style="color:white;text-decoration:none;font-size:12px;">关闭 </a> </div>'
var AdContentHtml1 = ' <img border="0" src="+ leftpic +">'; //指定左侧的广告图片位置
var AdContentHtml2 = ' <img border="0" src="+ rightpic +">'; //指定右侧的广告图片位置
document.write (' <div id="Javascript.LeftDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ClosebuttonHtml+' <div>'+AdContentHtml1+' </div> </div>');
document.write (' <div id="Javascript.RightDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ClosebuttonHtml+' <div>'+AdContentHtml2+' </div> </div>');
window.onscroll=scall;
window.onresize=scall;
window.onload=scall;
function scall()
{
if(!showad){return;}
if (window.screen.width <MinScreenW)
{
alert("临时提示:\n\n显示器分辨率宽度小于"+MinScreenW+",不显示广告");
showad = false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
return;
}
var Borderpx = ((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;
} function hidead()
{
showad = false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
} }
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" src="js/duilian.js" ></script>
<script type="text/javascript">
<!--
setshowad("300","300","http://www.baidu.com/img/baidu.gif","http://www.baidu.com/img/baidu.gif","100");
-->
</script>
</head>
<body>
<form id="form1" runat="server">
</form>
</body>
</html>
<head runat="server">
<title>无标题页 </title>
<script type="text/javascript" src="js/duilian.js" > </script>
<script type="text/javascript">
<!--
setshowad("300","300","http://www.baidu.com/img/baidu.gif","http://www.baidu.com/img/baidu.gif","100");
-->
</script>
</head>
<body>
<form id="form1" runat="server">
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</form>
</body>
</html>
function setshowad(leftpic,rightpic,AdW,AdH,AdTop)
{
var showad = true;
var Toppx = AdTop; //上端位置
var AdDivW = 110; //宽偏移量
var AdDivH = 6; //高偏移量
var PageWidth = 800; //页面多少宽度象素下正好不出现左右滚动条
var MinScreenW = 1024; //显示广告的最小屏幕宽度象素 var ClosebuttonHtml = ' <div align="right" style="position: absolute;top:0px;right:0px;margin:0px;padding:0px;z-index:2000;"> <a href="javascript:;" onclick="hidead()" style="color:white;text-decoration:none;font-size:12px;">关闭 </a> </div>'
var AdContentHtml1 = ' <img border="0" src="+ leftpic +" width="+ AdW +" height="+ AdH +">'; //指定左侧的广告图片位置
var AdContentHtml2 = ' <img border="0" src="+ rightpic +" width="+ AdW +" height="+ AdH +">'; //指定右侧的广告图片位置
document.write (' <div id="Javascript.LeftDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ClosebuttonHtml+' <div>'+AdContentHtml1+' </div> </div>');
document.write (' <div id="Javascript.RightDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ClosebuttonHtml+' <div>'+AdContentHtml2+' </div> </div>');
window.onscroll=scall;
window.onresize=scall;
window.onload=scall;
function scall()
{
if(!showad){return;}
if (window.screen.width <MinScreenW)
{
alert("临时提示:\n\n显示器分辨率宽度小于"+MinScreenW+",不显示广告");
showad = false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
return;
}
var Borderpx = ((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;
} function hidead()
{
showad = false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
} }
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
var showad = true;
var AdDivW = 110; //宽偏移量
var AdDivH = 6; //高偏移量
var PageWidth = 800; //页面多少宽度象素下正好不出现左右滚动条
var MinScreenW = 1024; //显示广告的最小屏幕宽度象素
function setshowad(leftpic,rightpic,AdW,AdH,AdTop)
{
var ClosebuttonHtml = ' <div align="right" style="position: absolute;top:0px;right:0px;margin:0px;padding:0px;z-index:2000;"> <a href="javascript:;" onclick="hidead()" style="color:white;text-decoration:none;font-size:12px;">关闭 </a> </div>'
var AdContentHtml1 = "<img border=0 src='"+ leftpic +"' width='"+ AdW +"' height='"+ AdH +"'>"; //指定左侧的广告图片位置
var AdContentHtml2 = "<img border=0 src='"+ rightpic +"' width='"+ AdW +"' height='"+ AdH +"'>"; //指定右侧的广告图片位置
document.write (' <div id="Javascript.LeftDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ClosebuttonHtml+' <div>'+AdContentHtml1+' </div> </div>');
document.write (' <div id="Javascript.RightDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ClosebuttonHtml+' <div>'+AdContentHtml2+' </div> </div>');
window.onscroll=function()
{
scall(AdTop);
}
window.onresize==function()
{
scall(AdTop);
}
}
function scall(Toppx)
{
if(!showad){return;}
if (window.screen.width <MinScreenW)
{
alert("临时提示:\n\n显示器分辨率宽度小于"+MinScreenW+",不显示广告");
showad = false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
return;
}
var Borderpx = ((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;
} function hidead()
{
showad = false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
} setshowad("http://www.baidu.com/img/baidu.gif","http://www.baidu.com/img/baidu.gif","100","300",100);
scall(100);</script>
</head><body>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
</body>
</html>