Rotate ad Code plus demo [JavaScript implementation]

Source: Internet
Author: User
Tags array window
Javascript| Advertising

  Demo effect:http://www.webjx.com/htmldata/2005-11-26/test.html

<script language= "JavaScript" >
<!--
var cpad=new Array ();
var cpadlink=new Array ();
var cpadmsg=new Array ();
5 Arrays defined
var adnum=5;
var coll=0;

Ad/1.html at that time you linked the ad address

Cpad[0]= "Banners/mba.gif";
Cpadlink[0]= "ad/1.html";
cpadmsg[0]= "1";

Cpad[1]= "Banners/google.gif";
cpadlink[1]= "Ad/2.html"
cpadmsg[1]= "2";

Cpad[2]= "Banners/2005.gif";
Cpadlink[2]= "ad/3.html";
cpadmsg[2]= "3";

Cpad[3]= "Banners/cz8y.gif";
Cpadlink[3]= "ad/4.html";
Cpadmsg[3]= "4";

Cpad[4]= "Banners/jg_yuedu.gif";
Cpadlink[4]= "ad/5.html";
cpadmsg[4]= "5";

var preloadedimages=new Array ();
for (i=1;i<cpad.length;i++) {
Preloadedimages[i]=new Image ();
Preloadedimages[i].src=cpad[i];
}

The URL address of the jump
function Jump2url ()
{
Jumpurl=cpadlink[adnum];
jumptarget= ' _blank ';
if (Jumpurl!= ')
{
if (Jumptarget!= ')
window.open (Jumpurl,jumptarget);
else Location.href=jumpurl;
}
}

Function of a picture change
function changeimg (n)
{
Adnum=n;
Switch (adnum)
{
Case 0:
{
Window.img1.src= "/uploadpic/2007-7/20077717158750.gif";
Window.img2.src= "/uploadpic/2007-7/20077717159630.gif";
Window.img3.src= "/uploadpic/2007-7/20077717159771.gif";
Window.img4.src= "4.gif";
Window.img5.src= "/uploadpic/2007-7/20077717159962.gif";
Break
}
Case 1:
{
Window.img1.src= "/uploadpic/2007-7/20077717159287.gif";
Window.img2.src= "/uploadpic/2007-7/20077717159359.gif";
Window.img3.src= "/uploadpic/2007-7/20077717159771.gif";
Window.img4.src= "4.gif";
Window.img5.src= "/uploadpic/2007-7/20077717159962.gif";
Break
}
Case 2:
{
Window.img1.src= "/uploadpic/2007-7/20077717159287.gif";
Window.img2.src= "/uploadpic/2007-7/20077717159630.gif";
Window.img3.src= "/uploadpic/2007-7/20077717159990.gif";
Window.img4.src= "4.gif";
Window.img5.src= "/uploadpic/2007-7/20077717159962.gif";
Break
}
Case 3:
{
Window.img1.src= "/uploadpic/2007-7/20077717159287.gif";
Window.img2.src= "/uploadpic/2007-7/20077717159630.gif";
Window.img3.src= "/uploadpic/2007-7/20077717159771.gif";
Window.img4.src= "/uploadpic/2007-7/20077717159187.gif";
Window.img5.src= "/uploadpic/2007-7/20077717159962.gif";
Break
}
Case 4:
{
Window.img1.src= "/uploadpic/2007-7/20077717159287.gif";
Window.img2.src= "/uploadpic/2007-7/20077717159630.gif";
Window.img3.src= "/uploadpic/2007-7/20077717159771.gif";
Window.img4.src= "4.gif";
Window.img5.src= "/uploadpic/2007-7/20077717159913.gif";
Break
}
}
Window.clearinterval (Thetimer);
Adnum=adnum-1;
Nextad ();
}
Jump directly when clicked
function Nextad () {
coll++;
if (coll>1)
{
Switch (adnum+1)
{
Case 5:
{
Window.img1.src= "/uploadpic/2007-7/20077717158750.gif";
Window.img2.src= "/uploadpic/2007-7/20077717159630.gif";
Window.img3.src= "/uploadpic/2007-7/20077717159771.gif";
Window.img4.src= "4.gif";
Window.img5.src= "/uploadpic/2007-7/20077717159962.gif";
Break
}
Case 1:
{
Window.img1.src= "/uploadpic/2007-7/20077717159287.gif";
Window.img2.src= "/uploadpic/2007-7/20077717159359.gif";
Window.img3.src= "/uploadpic/2007-7/20077717159771.gif";
Window.img4.src= "4.gif";
Window.img5.src= "/uploadpic/2007-7/20077717159962.gif";
Break
}
Case 2:
{
Window.img1.src= "/uploadpic/2007-7/20077717159287.gif";
Window.img2.src= "/uploadpic/2007-7/20077717159630.gif";
Window.img3.src= "/uploadpic/2007-7/20077717159990.gif";
Window.img4.src= "4.gif";
Window.img5.src= "/uploadpic/2007-7/20077717159962.gif";
Break
}
Case 3:
{
Window.img1.src= "/uploadpic/2007-7/20077717159287.gif";
Window.img2.src= "/uploadpic/2007-7/20077717159630.gif";
Window.img3.src= "/uploadpic/2007-7/20077717159771.gif";
Window.img4.src= "/uploadpic/2007-7/20077717159187.gif";
Window.img5.src= "/uploadpic/2007-7/20077717159962.gif";
Break
}
Case 4:
{
Window.img1.src= "/uploadpic/2007-7/20077717159287.gif";
Window.img2.src= "/uploadpic/2007-7/20077717159630.gif";
Window.img3.src= "/uploadpic/2007-7/20077717159771.gif";
Window.img4.src= "4.gif";
Window.img5.src= "/uploadpic/2007-7/20077717159913.gif";
Break
}
}
}
if (adnum<cpad.length-1) adnum++;
else adnum=0;
Settransition ();
Document.images.cpadrush.src=cpad[adnum];
Playtransition ();
Displaystatusmsg ();
5s of rotation time defined
Thetimer=settimeout ("Nextad ()", 5000);
}

function Settransition () {
if (document.all) {
cpadrush.filters.revealtrans.transition=23;
CpADrush.filters.revealTrans.apply ();
}

}
function Playtransition () {
if (document.all)
CpADrush.filters.revealTrans.play ()
}
function Displaystatusmsg () {
Status=cpadmsg[adnum];
Document.returnvalue = true;
}
End
-->

</script>



<table height= "148" cellspacing= "0" cellpadding= "0" >
<tr>
<td> <a href= "Javascript:jump2url ()" > </a></td>
<script language= "JavaScript" >nextad () </script>
</tr>
<tr>
<td>
<table width= "575" name= "T1" id= "T1" border= "0" cellspacing= "1" cellpadding= "0" >
<tr>
&LT;TD align= "right" ></td>"
&LT;TD width= "><a href=" # "></a></td>"
&LT;TD width= "><a href=" # "></a></td>"
&LT;TD width= "><a href=" # "></a></td>"
&LT;TD width= ><a href= "#" ></td>
&LT;TD width= "><a href=" # "></a></td>"
</tr>
</table>
</td>
</tr>
</table>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.