牵狗和拖死狗还是JS!方便快捷,狗死了只需删除或重命名JS文件了事!
现特发布一段狗狗的JS代码:)
希望大家用得开心,有分的请加分,有精的请加精,谢谢:)
======================================
首先建一个文件名为adbanner的JS,代码如下:
CODE: [Copy to clipboard]
<!-- AD rotator script written entirely in JavaScript -->
<!-- Written by WenWei, 2002/03/03. E-mail: wenwei@blueidea.com -->
<!-- ASP 2 JS Written by 小荷, 2003/05/28. E-mail: aston314@sohu.com -->
<!-- Member Of Blueidea Web Team. -->
<!-- Welcome to www.blueidea.com. -->
function runCode() //定义一个运行代码的函数,
{
var code=event.srcElement.parentElement.children[0].value;//即要运行的代码。
var newwin=window.open('','',''); //打开一个窗口并赋给变量newwin。
newwin.opener = null // 防止代码对论谈页面修改
newwin.document.write(code); //向这个打开的窗口中写入代码code,这样就实现了运行代码功能。
newwin.document.close();
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v3.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible'v='hide')?'hidden':v; }
obj.visibility=v; }
}
// AD Banner object
function ADBanner(){
this.htmlcode = "";// Non image banner's html code
this.href = "";// Link's href attrib
this.imgsrc = "";// Image's src attrib
this.imgwidth = "";// Image's width attrib
this.imgheight = "";// Image's height attrib
this.imgalt = "";// Image's alt attrib
this.imgborder = "";// Image's border attrib
this.weight = 1;// Banner's show weight
this.place = 1// Banner's place
this.type = 1;// Banner's type
}
// Make Banner objects array
function CreatBanners(aBanners, aNum){
for( var i=0; i<aNum; i++ ){
aBanners = new ADBanner();
}
}
// Show banner
function showbanner(aPlace, aType, aBannerID)
{
var amount = ADBanners.length;
var includeList = new Array(amount);
if (!document.usedBanners){
document.usedBanners = new Array(amount);
for (var i=0; i<amount; i++)
document.usedBanners = -1;
}
var usedList = document.usedBanners;
if (arguments.length == 2){
var j = 0;
var sum = 0;
for(var i=0; i<amount; i++){
if (ADBanners.place == aPlace && ADBanners.type == aType){
if (usedList != i){
includeList[j] = i;
j++;
sum = sum + ADBanners.weight;
}
}
}
if (sum <= 0)
return;
var rndNum = Math.round(Math.random() * sum);
i = 0;
j = 0;
while (true) {
j = j + ADBanners[includeList].weight;
if (j >= rndNum)
break;
i++;
}
i = includeList;
}
else{
if (aBannerID >= 0 && aBannerID < amount)
i = aBannerID;
else
return;
}
usedList = i;
if (ADBanners.htmlcode == "")
document.write('<A HREF="'+ ADBanners.href +'" target=_blank><IMG SRC="'+ ADBanners.imgsrc +'" WIDTH="'+ ADBanners.imgwidth +'" HEIGHT="'+ ADBanners.imgheight +'" ALT="'+ ADBanners.imgalt +'" BORDER="'+ ADBanners.imgborder +'"></A>');
else
document.write(ADBanners.htmlcode);
}
var ADBanners = new Array();
CreatBanners(ADBanners, 1);
ADBanners[0].htmlcode = '<script type="text/javascript">google_ad_client = "pub-0614643359718668";google_ad_width = 728;google_ad_height = 90;google_ad_format = "728x90_as";google_ad_channel ="";google_color_border = "FF4500";google_color_bg = "FFEBCD";google_color_link = "DE7008";google_color_url = "E0AD12";google_color_text = "8B4513";</script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';
ADBanners[0].weight = 20;
ADBanners[0].place= 6;
ADBanners[0].type = 6;
此代码当中CreatBanners(ADBanners, 1); 这里的数字设置广告数量,如果只放一个GOOGLE就设置1了.,
ADBanners[0].htmlcode = 这里里面填写GOOGLE AD的广告代码,请注意,必须写成一行
ADBanners[0].place= 6;
ADBanners[0].type = 6; 要调用的序号,具体偶不清楚,哈哈
弄好后,在网页HEAD中插入
<script language="JavaScript" src="adbanner.js"></script>
在要放广告的地方插入
<SCRIPT language=JavaScript>showbanner(6,6);</SCRIPT>
这里的数字是和 ADBANNER里的数字对应的,
<img src="../images/emptylogo.gif" border="0">
……完…… |