0

I have a script that grants scrolling of information.

Visit http://richardtamm.com to see what I am talking about. Look in the footer for the blog feed.

I was able to take the code and place it in a .css script so I didn't have the additional properties clogging up my header.

I would like to do the same for the portion of the used code.

I am including the code used for reference.

<style type="text/css">

#marqueecontainer{
position: relative;
width: 200px; /*marquee width */
height: 200px; /*marquee height */
background-color: white;
overflow: hidden;
border: 3px solid orange;
padding: 2px;
padding-left: 4px;
}
</style>

CSS style for page.

<div id="marqueecontainer" onMouseover="M1.Speed=0;" onMouseout="M1.Speed=1;">
<div style="position: absolute; width: 98%;">

***CONTENT**

</div>
</div>

Code for to have Marquee inside a sizabe Div

<script  type="text/javascript">
/*<![CDATA[*/
function Marquee(o){
 var oop=this,obj=document.getElementById(o.ID),top=0;
 var marquee=obj.getElementsByTagName('DIV')[0];
 this.marqueeheight=marquee.offsetHeight;
 marquee.style.top=-this.marqueeheight+'px';

 this.marquee=[marquee];
 while (top<obj.offsetHeight){
  marquee=marquee.cloneNode(true);
  marquee.style.top=top+'px';
  obj.appendChild(marquee);
  this.marquee.push(marquee);
  top+=this.marqueeheight;
 }

 this.Speed=o.marqueespeed;
 setTimeout(function(){ setInterval(function(){ oop.scroll(); },30); }, o.delayb4scroll)
}

Marquee.prototype.scroll=function(){
 for (var top,z0=0;z0<this.marquee.length;z0++){
  top=parseInt(this.marquee[z0].style.top)-this.Speed
  this.marquee[z0].style.top=top+"px";
  if (top<-this.marqueeheight){
   this.marquee[z0].style.top=top+this.marqueeheight*this.marquee.length+"px";
  }
 }
}

/*]]>*/
</script>
<script type="text/javascript">
/*<![CDATA[*/

var M1=new Marquee({
 ID:'marqueecontainer',
 delayb4scroll:2000, //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
 marqueespeed:2 //Specify marquee scroll speed (larger is faster 1-10)
});


var M2=new Marquee({
 ID:'marqueecontainer2',
 delayb4scroll:2000, //Specify initial delay before marquee starts to scroll on page         (2000=2 seconds)
 marqueespeed:2 //Specify marquee scroll speed (larger is faster 1-10)
});


/*]]>*/
</script>

JaveScript for the marquee to function...This is the information I would like in one or two .js files so all that code isn't in my footer.

Any help would be great.

I tried to remove the attributes and place the rest in a file i name marquee.js and marquee2.js

then put

<script src="location/marquee.js"></script>
<script src="location/marquee2.js"></script>

In place of the full script and it didn't work.

Brainfeeder
  • 2,604
  • 2
  • 19
  • 37
RLTamm
  • 3
  • 3
  • As a side note, you don't need the `/*<![CDATA[*/` and `/*]]>*/` wrapped around inline scripts on that page. The page has the doctype ` `, which is a HTML 5 doctype. The `CDATA` wrapper is [only needed for XHTML/XML documents](http://stackoverflow.com/questions/66837/when-is-a-cdata-section-necessary-within-a-script-tag). – Useless Code Feb 22 '14 at 01:07
  • Thank you... This was known but I left it in there since I was copy paste from txt doc.. Thanks though. – RLTamm Feb 22 '14 at 01:14
  • I solved this issue myself. I was not calling the id for the < div> with the script code. Moving imformation between the < script> tags and placing in a .js file worked when i added the
    id i used
    – RLTamm Feb 22 '14 at 01:19

0 Answers0