Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    51
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Code not working.

    So..as per my usual spiel, Javascript and I have a very rocky relationship. My job recently dumped the company website onto me and I was trying to update this one page. I copied the code from the module on the demo site, to the equivalent module on the live site. And suddenly the code wasn't working... I had backed up the old code but reputting that in didn't work either, which makes no sense... If the code didn't change, I don't understand why it suddenly wouldn't work. But, here's the code. Can you see anything wrong with it?

    Code:
    <table cellspacing="0" cellpadding="0" border="0" style="margin-bottom:13px"> 
    	<tbody> 
    	<tr> 
    		<td style="color:#fff; padding-left:15px; font-weight:bold">
    			<a href="/Portals/0/ProObjectEventsFeed.xml" target="_blank">
    				<img align="absmiddle" width="36" height="14" border="0" src="/Portals/0/images/rss/rss.gif" alt="ProObject RSS Feed" />
    			</a> Corporate Events: 
    			<script type="text/javascript"> <!-- //--><![CDATA[//>
    				<!-- var delay = 4000; //set delay between message change (in miliseconds) 
    				var maxsteps=30; // number of steps to change from start color to endcolor 
    				var stepdelay=40; // time in miliseconds of a single step 
    				var startcolor= new Array(18,68,101); // start color (red, green, blue) 
    				var endcolor=new Array(255,255,255); // end color (red, green, blue) 
    				var fcontent=new Array(); 
    				begintag='<span style="padding-left:5px">'; 
    				fcontent[0]="<a style='text-decoration:none' href='Company/CorporateEvents/tabid/213/Default.aspx#26_Feb_11'>February 26, 2011 - ProObject sponsored 42 athletes and 11 volunteers at the Tri-to-Help Triathlon held in Baltimore, Maryland"; 
    				fcontent[1]="<a style='text-decoration:none' href='Company/CorporateEvents/tabid/213/Default.aspx#30_Jan_11'>January 30, 2011 - ProObject held its Annual Duck Pin Bowling Event at the Glen Burnie Bowl Center"; 
    				fcontent[2]="<a style='text-decoration:none' href='Company/CorporateEvents/tabid/213/Default.aspx#20_Jan_11'>ProObject is proud to be the new home of the Baltimore SharePoint Users Group (BSPUG)</a>"; 
    				closetag='</span>'; 
    				var fwidth=''; //set scroller width 
    				var fheight=''; //set scroller height 
    				var fadelinks=1; // links inside scroller also fade like text? 0 no, 1 yes 
    				var ie4=document.all&&!document.getElementById; 
    				var DOM2=document.getElementById; 
    				var faderdelay=0; 
    				var index=0; 
    				
    				function changecontent(){ 
    					if (index>=fcontent.length) index=0 
    					if (DOM2){ 
    						document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")" document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag if (fadelinks) linkcolorchange(1); colorfade(1, 15); 
    					} 
    					else if (ie4) document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag; index++ 
    				} //Dynamicdrive.com 
    				
    				function linkcolorchange(step){ 
    					var obj=document.getElementById("fscroller").getElementsByTagName("A"); 
    					if (obj.length>0){ 
    						for (i=0;i<obj.length;i++) obj[i].style.color=getstepcolor(step); 
    					} 
    				} 
    				var fadecounter; 
    				function colorfade(step) { 
    					if(step<=maxsteps) { 
    						document.getElementById("fscroller").style.color=getstepcolor(step); 
    						if (fadelinks) linkcolorchange(step); 
    						step++; 
    						fadecounter=setTimeout("colorfade("+step+")",stepdelay); 
    					}else{ 
    						clearTimeout(fadecounter); 
    						document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")"; setTimeout("changecontent()", delay); 
    					}
    				} 
    				
    				function getstepcolor(step) { 
    					var diff var newcolor=new Array(3); 
    					for(var i=0;i<3;i++) { 
    						diff = (startcolor[i]-endcolor[i]); 
    						if(diff > 0) { 
    							newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step); 
    						} else { newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step); 
    						} 
    					} return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")"); 
    				} 
    				
    				if (ie4||DOM2) document.write('<span id="fscroller"></span>'); 
    				if (window.addEventListener) window.addEventListener("load", changecontent, false) 
    				else if (window.attachEvent) window.attachEvent("onload", changecontent) 
    				else if (document.getElementById) window.onload=changecontent //--><!]]> 
    			</script>
    		</td> </tr> 
    </tbody> </table>

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    see changes in red

    Code:
    <!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" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    </head>
    
    <body>
    <table cellspacing="0" cellpadding="0" border="0" style="margin-bottom:13px">
    	<tbody>
    	<tr>
    		<td style="color:#fff; padding-left:15px; font-weight:bold">
    			<a href="/Portals/0/ProObjectEventsFeed.xml" target="_blank">
    				<img align="absmiddle" width="36" height="14" border="0" src="/Portals/0/images/rss/rss.gif" alt="ProObject RSS Feed" />
    			</a> Corporate Events:
    			<script type="text/javascript"> <!-- //--><![CDATA[//>
    				<!-- var delay = 4000; //set delay between message change (in miliseconds)
    				var maxsteps=30; // number of steps to change from start color to endcolor
    				var stepdelay=40; // time in miliseconds of a single step
    				var startcolor= new Array(18,68,101); // start color (red, green, blue)
    				var endcolor=new Array(255,255,255); // end color (red, green, blue)
    				var fcontent=new Array();
    				begintag='<span style="padding-left:5px">';
    				fcontent[0]="<a style='text-decoration:none' href='Company/CorporateEvents/tabid/213/Default.aspx#26_Feb_11'>February 26, 2011 - ProObject sponsored 42 athletes and 11 volunteers at the Tri-to-Help Triathlon held in Baltimore, Maryland";
    				fcontent[1]="<a style='text-decoration:none' href='Company/CorporateEvents/tabid/213/Default.aspx#30_Jan_11'>January 30, 2011 - ProObject held its Annual Duck Pin Bowling Event at the Glen Burnie Bowl Center";
    				fcontent[2]="<a style='text-decoration:none' href='Company/CorporateEvents/tabid/213/Default.aspx#20_Jan_11'>ProObject is proud to be the new home of the Baltimore SharePoint Users Group (BSPUG)</a>";
    				closetag='</span>';
    				var fwidth=''; //set scroller width
    				var fheight=''; //set scroller height
    				var fadelinks=1; // links inside scroller also fade like text? 0 no, 1 yes
    				var ie4=document.all&&!document.getElementById;
    				var DOM2=document.getElementById;
    				var faderdelay=0;
    				var index=0;
    
    				function changecontent(){
    					if (index>=fcontent.length) index=0
    					if (DOM2){
    						document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")";
                            document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag;
                            if (fadelinks) linkcolorchange(1);
                            colorfade(1, 15);
    					}
    					else if (ie4) document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag; index++
    				} //Dynamicdrive.com
    
    				function linkcolorchange(step){
    					var obj=document.getElementById("fscroller").getElementsByTagName("A");
    					if (obj.length>0){
    						for (i=0;i<obj.length;i++) obj[i].style.color=getstepcolor(step);
    					}
    				}
    				var fadecounter;
    				function colorfade(step) {
    					if(step<=maxsteps) {
    						document.getElementById("fscroller").style.color=getstepcolor(step);
    						if (fadelinks) linkcolorchange(step);
    						step++;
    						fadecounter=setTimeout("colorfade("+step+")",stepdelay);
    					}else{
    						clearTimeout(fadecounter);
    						document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
                            setTimeout("changecontent()", faderdelay);
    					}
    				}
    
    				function getstepcolor(step) {
    					var diff;
                         var newcolor=new Array(3);
    					for(var i=0;i<3;i++) {
    						diff = (startcolor[i]-endcolor[i]);
    						if(diff > 0) {
    							newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
    						} else { newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
    						}
    					} return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
    				}
    
    				if (ie4||DOM2) document.write('<span id="fscroller"></span>');
    				if (window.addEventListener) window.addEventListener("load", changecontent, false)
    				else if (window.attachEvent) window.attachEvent("onload", changecontent)
    				else if (document.getElementById) window.onload=changecontent //--><!]]>
    			</script>
    		</td> </tr>
    </tbody> </table>
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • Users who have thanked vwphillips for this post:

    hunter1611 (09-04-2013)

  • #3
    New Coder
    Join Date
    Jan 2011
    Posts
    51
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Thank you!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •