Bounce Style Marquee Script
You can put any
HTML
in
here. Adjust the various settings in the script to get the effect you want.
You can use this script as a cross-browser replacement for IE's built-in
MARQUEE
tag (which doesn't work in anything except IE).
Instructions:
1: Copy and paste the following Javascript in the BODY section of your page:
Select all...
<script language="javascript"> //ENTER CONTENT TO SCROLL BELOW. var content='You can put any <b>HTML</b> <font color="red">in</font> here. Adjust the various settings in the script to get the effect you want.'; var boxheight=60; // BACKGROUND BOX HEIGHT IN PIXELS. var boxwidth=400; // BACKGROUND BOX WIDTH IN PIXELS. var elementwidth=250; // WIDTH OF SCROLLING CONTENT IN PIXELS. EXPERIMENT TO FIND THE VALUES. var boxcolor="#ffedcf"; // BACKGROUND BOX COLOR. var speed=50; // SPEED OF SCROLL IN MILLISECONDS (1 SECOND=1000 MILLISECONDS).. var pixelstep=2; // PIXELS "STEPS" PER REPITITION. var outer, inner; var goingright=true; var w3c=(document.getElementById)?true:false; var ns4=(document.layers)?true:false; var ie4=(document.all && !w3c)?true:false; var ie5=(document.all && w3c)?true:false; var ns6=(w3c && navigator.appName.indexOf("Netscape")>=0)?true:false; elementwidth=Math.min(boxwidth-4,elementwidth); var txt=(ns4)? '<table border=0 cellpadding=0 cellspacing=0 width='+boxwidth+' height='+boxheight+'><tr><td><ilayer name="outer" bgcolor="'+boxcolor+'" visibility="visible" width="'+boxwidth+'" height="'+boxheight+'" clip="'+boxheight+'">' : '<div id="outer" style="position:relative; width:'+boxwidth+'; height:'+boxheight+'; visibility:visible; background-color:'+boxcolor+'; overflow:hidden; text-align:left" >'; txt+=(ns4)? '<layer name="inner" visibility="hidden" width="'+elementwidth+'" left="2" top="2">' : '<div id="inner" style="position:absolute; visibility:hidden; left:2px; top:2px; width:'+elementwidth+'; overflow:hidden">'; txt+=content; txt+=(ns4)? '</layer></ilayer></td></tr></table>' : '</div></div>' ; document.write(txt); function init(){ inner=(ns4)?document.layers['outer'].document.layers['inner']:(ie4)?document.all['inner']:document.getElementById('inner'); if(ns4){ document.layers['outer'].clip.height=boxheight; document.layers['outer'].clip.width=boxwidth; inner.clip.width=elementwidth; inner.clip.height=boxheight-4; inner.visibility="show"; }else{ inner.style.clip='rect(0px, '+elementwidth+'px, '+(boxheight-4)+'px, 0px)'; inner.style.visibility="visible"; } goingright=true; setInterval('bouncescroll()',speed); } function bouncescroll(){ if(ns4){ if(inner.left>=(boxwidth-elementwidth))goingright=false; if(inner.left<=2)goingright=true; inner.left=(goingright)?inner.left+pixelstep :inner.left-pixelstep; }else{ if(parseInt(inner.style.left)>=(boxwidth-elementwidth))goingright=false; if(parseInt(inner.style.left)<=2)goingright=true; inner.style.left=((goingright)? parseInt(inner.style.left)+pixelstep: parseInt(inner.style.left)-pixelstep)+'px'; }} window.onload=init; </script>
2: Edit the Marquee string and adjust the settings in the script to suit your taste.