...

View Full Version : Help: News ticker js not working on IE8 & 9



ough
03-14-2012, 06:46 PM
Hello,

I built a fairly simple page using mioplanet's javascript code for a news ticker. It works fairly well on Chrome, Firefox, Safari and IE7, but IE8 and IE9 can't display it properly.

The website is here (http://www.ahahumanidade.com), and I ran it through w3c validator that pointed out multiple errors with divs nor properly closed (> missing), but on the code they're all there. I suspect the js is doing something funny, but I don't have enough knowledge to understand it.

I'm posting the js code as customised by me:


TICKER1_CONTENT = document.getElementById("TICKER1").innerHTML;

TICKER1_RIGHTTOLEFT = false;
TICKER1_SPEED = 5;
TICKER1_STYLE = "font-family:inconsolata,courier new, courier, monospace; font-size:24px; color:#ff00cc; letter-spacing:1px";
TICKER1_PAUSED = false;

TICKER1_start();

function TICKER1_start() {
var tickerSupported = false;
TICKER1_WIDTH = document.getElementById("TICKER1").style.width;
var img = "<img src=TICKER1_space.gif width="+TICKER1_WIDTH+" height=0>";

// Firefox
if (navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1) {
document.getElementById("TICKER1").innerHTML = "<TABLE cellspacing='0' cellpadding='0' width='100%'><TR><TD nowrap='nowrap'>"+img+"<SPAN style='"+TICKER1_STYLE+"' ID='TICKER1_BODY' width='100%'>&nbsp;</SPAN>"+img+"</TD></TR></TABLE>";
tickerSupported = true;
}
// IE
if (navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1) {
document.getElementById("TICKER1").innerHTML = "<DIV nowrap='nowrap' style='width:100%;'>"+img+"<SPAN style='"+TICKER1_STYLE+"' ID='TICKER1_BODY' width='100%'></SPAN>"+img+"</DIV>";
tickerSupported = true;
}
if(!tickerSupported) document.getElementById("TICKER1").outerHTML = ""; else {
document.getElementById("TICKER1").scrollLeft = TICKER1_RIGHTTOLEFT ? document.getElementById("TICKER1").scrollWidth - document.getElementById("TICKER1").offsetWidth : 0;
document.getElementById("TICKER1_BODY").innerHTML = TICKER1_CONTENT;
document.getElementById("TICKER1").style.display="block";
TICKER1_tick();
}
}

function TICKER1_tick() {
if(!TICKER1_PAUSED) document.getElementById("TICKER1").scrollLeft += TICKER1_SPEED * (TICKER1_RIGHTTOLEFT ? -1 : 1);
if(TICKER1_RIGHTTOLEFT && document.getElementById("TICKER1").scrollLeft <= 0) document.getElementById("TICKER1").scrollLeft = document.getElementById("TICKER1").scrollWidth - document.getElementById("TICKER1").offsetWidth;
if(!TICKER1_RIGHTTOLEFT && document.getElementById("TICKER1").scrollLeft >= document.getElementById("TICKER1").scrollWidth - document.getElementById("TICKER1").offsetWidth) document.getElementById("TICKER1").scrollLeft = 0;
window.setTimeout("TICKER1_tick()", 30);
}

and this is how it's referred on the html file:


<div id=tick1>
<div id="TICKER1" STYLE="overflow:hidden; width:1600px">
text here
</div>
<script type="text/javascript" src="webticker_1.js" language="javascript"></script>

any help much appreciated.

Thanks,

H



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum