Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Rotate linked banners with a fade

Posted on 2009-05-19
2
594 Views
Last Modified: 2013-12-25
Hello,
I have 5 banners with links to within my site that I want to rotate on my home page. I would also like to have these banners transition with a fade if possible.

I've been able to locate code that takes care of the rotation piece but it only works in IE (see below).

Any assistance is greatly appreciated.

Thanks!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
 
</head>
 
<body>
<ilayer id="l1">
	<layer id="l2">
		<div id="l1">
			<div id="l3" style="position:relative">
			</div>
		</div>
	</layer>
</ilayer>
<script language="JavaScript">
<!--
 
// ***********************************************
// AUTHOR: WWW.CGISCRIPT.NET, LLC
// URL: http://www.cgiscript.net
// Use the script, just leave this message intact.
// Download your FREE CGI/Perl Scripts today!
// ( http://www.cgiscript.net/scripts.htm )
// ***********************************************
 
var bannerArray = new Array();
var myCount=0;
// Banner Code Assignment
bannerArray[0] = "<A HREF=\"http://www.aceinstall.com\"><IMG SRC=\"http://ads.yimg.com/eur.yimg.com/a/eu/any/adscenter/adimage.gif\" border=\"0\" width=\"468\" height=\"60\"></A>";
bannerArray[1] = "<A HREF=\"http://www.cgiscript.net\"><IMG SRC=\"http://hamovhotov.com/advertisement/wp-content/uploads/2007/03/468x60ad.gif\" border=\"0\" width=\"468\" height=\"60\"></A>";
bannerArray[2] = "<A HREF=\"http://www.aceinstall.com\"><IMG SRC=\"http://www.outdoored.com/Store/Images/products/OE/468x60.gif\" border=\"0\" width=\"468\" height=\"60\"></A>";
 
bannerRotate();
 
function bannerRotate() {
 
if(myCount > bannerArray.length-1){myCount=0;}
 
// Write out rotation
	if (document.all){			// it is IE
		document.all.l3.innerHTML=bannerArray[myCount];
	}
 
	else if (document.layers){	// it is NN
 
	document.layers.l1.document.layers.l2.document.open();
	document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
	document.layers.l1.document.layers.l2.document.close();
	}
setTimeout("bannerRotate()", 3000);
myCount++;
}
// -->
</script>
</body>
</html>

Open in new window

0
Comment
Question by:wattanabi2
2 Comments
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
ID: 24428629
Hi wattanabi2,
Ok, i've amended the code for rotation that work for other browser like firefox. If you're looking for fade effect, that may only work in i.e version. Check this article:
http://brainerror.net/scripts/javascript/blendtrans/
....//existing code 
if (document.all){                      // it is IE
                document.all.l3.innerHTML=bannerArray[myCount];
        }
 
        else if (document.layers){      // it is NN
 
        document.layers.l1.document.layers.l2.document.open();
        document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
        document.layers.l1.document.layers.l2.document.close();
        }
	else if (document.getElementById){
         //add this line... 
         document.getElementById("l3").innerHTML=bannerArray[myCount];
        }

Open in new window

0
 

Author Closing Comment

by:wattanabi2
ID: 31583277
Thanks x_com. While I'm still missing the fade piece, this gets me off to a good start. I'll take a look at the link and will try to work in the fade piece from there.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question