Tuesday, January 20, 2009

Image rotator embedding in a content editor webpart.

Place the images in a image library(eg, http://SiteCollName/sites/sitename/doclibname/Image3.JPG")
now, copy paste the below code in the content editor webpart.
<script language="JavaScript">
<!--function adArray()
{for (i=0; i*2<adArray.arguments.length; i++)
{
this[i] = new Object();
this[i].src = adArray.arguments[i*2];
this[i].href = adArray.arguments[i*2+1];}this.length = i;
}

function getAdNum()
{
dat = new Date();
dat = (dat.getTime()+"").charAt(8);
if (dat.length == 1)ad_num = dat%ads.length;
elsead_num = 0;return ad_num;
}
var ads = new adArray("http://google.com/",
"http://SiteCollName/sites/sitename/doclibname/Image2.JPG","http://www.microsoft.com",
"http://SiteCollName/sites/sitename/doclibname/Image3.JPG","http://www.google.com",
"http://SiteCollName/sites/sitename/doclibname/Image4.JPG","http://www.google.com");
var ad_num = getAdNum();
document.write('<div align="center"><A HREF="'+ads[ad_num].href+'" target="_blank"><IMG SRC="'+ads[ad_num].src+'" '+'BORDER=0 name=js_ad></A></div>');
link_num = document.links.length-1;
function rotateSponsor() 
{
  if (document.images) 
  {
   ad_num = (ad_num+1)%ads.length;
   document.js_ad.src = ads[ad_num].src;
   document.links[link_num].href = ads[ad_num].href;
   setTimeout("rotateSponsor()",4000);
}
}
setTimeout("rotateSponsor()",4000);// --></script>



source: http://armsinfragilehands.blogspot.com/2008/10/sharepoint-image-rotator.html

No comments:

Post a Comment