关闭

渐隐渐现的广告图片轮显类dh_adShow

1361人阅读 评论(0) 收藏 举报
支持多实例:
P.S.:请大家在实际的代码编写中正确书写标签,如<p></p>,本例中有的只有<p>单个标签,未有结束标签是为了做容错测试!

The Class:

<script language="javascript">
function dhAdShow(){
//author:dh20156;
this.bannerAd = new Array();
this.width = 609;
this.height = 80;
this.target = "newWindow";
this.targetObj = null;
this.objAID = ("dh_adLink"+Math.random()).replace(//./g,"");
this.objIID = ("dh_adImg"+Math.random()).replace(//./g,"");

function ow(obj){
URL = obj.href;
window.open(URL);
return false;
}

this.setup = function(){
var objA = document.createElement("A");
var objI = document.createElement("IMG");
objA.id = this.objAID;
objA.href = "#";
objA.title = "dh_adShow";
if(this.target == "newWindow"){
objA.onclick = function(){return ow(this);}
}
objI.id = this.objIID;
objI.style.filter = "blendTrans(duration=2)";
objI.width = this.width;
objI.height = this.height;
objI.border = 0;
objI.alt = "dh_adShow";

objA.appendChild(objI);

if(this.bannerAd.length > 0){
objI.src = this.bannerAd[0].src;
objI.alt = this.bannerAd[0].tips;
objA.href = this.bannerAd[0].url;
objA.title = this.bannerAd[0].tips;
}

if(this.targetObj == null || this.targetObj == "document.body"){
var scriptObj = document.getElementsByTagName("script");
for(var i=0;i<scriptObj.length;i++){
if(scriptObj[i].innerHTML.indexOf("new dhAdShow()") > -1 && scriptObj[i].parentElement.tagName != "HEAD"){
this.targetObj = scriptObj[i].parentElement;
}
}
}

alert(this.objIID+";"+this.objAID);

this.targetObj.appendChild(objA);
}

this.step = 1;
this.slideShow = function(){
var oa = eval("document.all."+this.objAID);
var oi = eval("document.all."+this.objIID);
if(this.bannerAd.length > 0 && oa != null && oi != null){
if(document.all){oi.filters.blendTrans.apply();}
oi.src = this.bannerAd[this.step].src;
oi.alt = this.bannerAd[this.step].tips;
oa.href = this.bannerAd[this.step].url;
oa.title = this.bannerAd[this.step].tips;
if (document.all){oi.filters.blendTrans.play();}
this.step = (this.step<(this.bannerAd.length-1))?(this.step+1):0;
(new Image()).src = this.bannerAd[this.step].src;
}
}
}
</script>

asdkfhkl<p>

<script language="javascript">
var bannerAd = new Array();
bannerAd[0] = {src:"images/ad/ad01.gif",url:"http://www.xingan.gov.cn/",tips:"新干政府"};
bannerAd[1] = {src:"images/ad/ad02.gif",url:"http://www.jxxg.com/",tips:"新干青铜传媒"};
bannerAd[2] = {src:"images/ad/ad03.gif",url:"http://www.xingan.gov.cn/",tips:"新干政府"};
bannerAd[3] = {src:"images/ad/ad04.gif",url:"http://www.jxxg.com/",tips:"新干在线"};
var dhss = new dhAdShow();
dhss.bannerAd = bannerAd;
dhss.setup();
setInterval("dhss.slideShow()",10000);
</script>

<p>asldkfhk

<p>lqweuyrpocpvb<p/>

<script language="javascript">
var bannerAd2 = new Array();
bannerAd2[0] = {src:"images/ad/ad01.gif",url:"http://www.xingan.gov.cn/",tips:"新干政府"};
bannerAd2[1] = {src:"images/ad/ad02.gif",url:"http://www.jxxg.com/",tips:"新干青铜传媒"};
bannerAd2[2] = {src:"images/ad/ad03.gif",url:"http://www.xingan.gov.cn/",tips:"新干政府"};
bannerAd2[3] = {src:"images/ad/ad04.gif",url:"http://www.jxxg.com/",tips:"新干在线"};
var dhss2 = new dhAdShow();
dhss2.bannerAd = bannerAd2;
dhss2.setup();
setInterval("dhss2.slideShow()",10000);
</script>
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:121257次
    • 积分:2019
    • 等级:
    • 排名:第19037名
    • 原创:73篇
    • 转载:4篇
    • 译文:1篇
    • 评论:98条
    文章分类
    最新评论