Try this out:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
/*
* OO Cross browser Marquee script- © Dynamic Drive (www.dynamicdrive.com)
* For full TOS source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
* Credit MUST stay intact
* Modified in http://www.dynamicdrive.com/forums by jscheuer1 * For multiple use
*/
var marqueecontent='<nobr><font face="Arial">Thank you for visiting <a href="http://www.dynamicdrive.com">Dynamic Drive.</a> If you find this script useful, please consider linking to us by <a href="../link.htm">click here.</a> Enjoy your stay!</font></nobr>'
var marqueecontent2='<nobr>And the text just keeps on whizzing by, no matter what you do!</nobr>'
//////////////// Stop Editing ////////////////
function cross_marquee(marqueecontent, marqueewidth, marqueeheight, marqueespeed, marqueebgcolor, pauseit){
if(!cross_marquee.ar)
cross_marquee.ar=[];
cross_marquee.ar[this.mqid=cross_marquee.ar.length]=this;
this.marqueecontent=marqueecontent;
this.marqueewidth=marqueewidth;
this.marqueeheight=marqueeheight;
this.marqueespeed=marqueespeed;
this.marqueebgcolor=marqueebgcolor;
this.pauseit=pauseit;
this.marqueespeed=(document.all)? this.marqueespeed : Math.max(1, this.marqueespeed-1) //slow speed down by 1 for NS
this.copyspeed=this.marqueespeed
this.pausespeed=(this.pauseit==0)? this.copyspeed: 0
this.iedom=document.all||document.getElementById
if (this.iedom)
document.write('<span id="temp'+this.mqid+'" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+this.marqueecontent+'</span>')
this.actualwidth=''
if (this.iedom||document.layers){
with (document){
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
if (this.iedom){
write('<div style="position:relative;width:'+this.marqueewidth+';height:'+this.marqueeheight+';overflow:hidden">')
write('<div style="position:absolute;width:'+this.marqueewidth+';height:'+this.marqueeheight+';background-color:'+this.marqueebgcolor+'" onMouseover="cross_marquee.ar['+this.mqid+'].copyspeed=cross_marquee.ar['+this.mqid+'].pausespeed" onMouseout="cross_marquee.ar['+this.mqid+'].copyspeed=cross_marquee.ar['+this.mqid+'].marqueespeed">')
write('<div id="iemarquee'+this.mqid+'" style="position:absolute;left:0px;top:0px"></div>')
write('</div></div>')
}
else if (document.layers){
write('<ilayer width='+this.marqueewidth+' height='+this.marqueeheight+' name="ns_marquee'+this.mqid+'" bgColor='+this.marqueebgcolor+'>')
write('<layer name="ns_marquee2'+this.mqid+'" left=0 top=0 onMouseover="cross_marquee.ar['+this.mqid+'].copyspeed=cross_marquee.ar['+this.mqid+'].pausespeed" onMouseout="cross_marquee.ar['+this.mqid+'].copyspeed=cross_marquee.ar['+this.mqid+'].marqueespeed"></layer>')
write('</ilayer>')
}
document.write('</td></table>')
}
}
this.populate();
}
cross_marquee.prototype.populate=function(){
if (this.iedom){
this.cross_marquee=document.getElementById? document.getElementById("iemarquee"+this.mqid) : document.all['iemarquee'+this.mqid];
this.cross_marquee.style.left=parseInt(this.marqueewidth)+8+"px"
this.cross_marquee.innerHTML=this.marqueecontent
this.actualwidth=document.all? document.all['temp'+this.mqid].offsetWidth : document.getElementById("temp"+this.mqid).offsetWidth;
}
else if (document.layers){
this.ns_marquee=document['ns_marquee'+this.mqid].document['ns_marquee2'+this.mqid];
this.ns_marquee.left=parseInt(marqueewidth)+8
this.ns_marquee.document.write(this.marqueecontent)
this.ns_marquee.document.close()
this.actualwidth=this.ns_marquee.document.width
}
var cacheobj=this;
this.lefttime=setInterval(function(){cacheobj.scrollmarquee();},20)
}
cross_marquee.prototype.scrollmarquee=function(){
if (this.iedom){
if (parseInt(this.cross_marquee.style.left)>(this.actualwidth*(-1)+8))
this.cross_marquee.style.left=parseInt(this.cross_marquee.style.left)-this.copyspeed+"px"
else
this.cross_marquee.style.left=parseInt(this.marqueewidth)+8+"px"
}
else if (document.layers){
if (this.ns_marquee.left>(this.actualwidth*(-1)+8))
this.ns_marquee.left-=this.copyspeed
else
this.ns_marquee.left=parseInt(this.marqueewidth)+8
}
}
</script>
</head>
<body>
<script type="text/javascript">
/*Explanation of Parameters:
marqueecontent //Specify the name of the array containing the marquee text
marqueewidth //Specify the marquee's width (in pixels) ex: "300px"
marqueeheight //Specify the marquee's height ex: "25px"
marqueespeed //Specify the marquee's marquee speed (larger is faster 1-10) ex: 2
marqueebgcolor //Specify background color ex: "#DEFDD9"
pauseit //Pause marquee onMousever (0=no. 1=yes)?
usage: new cross_marquee(marqueecontent, marqueewidth, marqueeheight, marqueespeed, marqueebgcolor, pauseit)
*/
new cross_marquee(marqueecontent, "300px", "25px", 2, "#DEFDD9", 1)
</script>
<br>
<script type="text/javascript">
new cross_marquee(marqueecontent2, "200px", "25px", 3, "#cccccc", 0)
</script>
</body>
</html>
Notes: The script now goes in the head and there are separate calls for each marquee in the body, as shown.
Bookmarks