[thelist] javascript scroller
Drew Shiel
ashiel at sportsinteraction.com
Tue Jul 22 05:17:40 CDT 2003
Hi folks;
I've been barking up wrong trees, chasing my tail and chewing rubber bones
here for the last couple of days on this; I'd appreciate some help before I
end up sleeping in a basket.
I have this javascript scroller/news ticker thing. It was written some
years ago, when the audience was IE and Netscape 4.x. Since then, Netscape
6+ has arrived along, and this scroller/ticker stopped working. I'm pasting
the HTML and the javascript below (the actual content is in another
javascript; it doesn't seem to be important, although I can provide a
sample if needed).
Any help in getting it rolling in Netscape 6+ would be great. If it could
be got to go in Opera, etc, that would be wonderful, but it's not
essential. Bear in mind that I'm not the hottest when it comes to
javascript; mostly I'm barking in the dark.
HTML:
<HTML>
<HEAD>
<TITLE>Live Odds from Sports Interaction</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
document.write("<SCRIPT
SRC='http://test.sportsinteraction.com/pages/oddsscroller/odds.js'>");
document.write("<\/SCRIPT>");
</SCRIPT>
<LINK REL=STYLESHEET TYPE="text/css"
HREF="http://test.sportsinteraction.com/pages/oddsscroller/oddsstylesheets.css"
TITLE="stylesheets/oddsstylesheets">
</HEAD>
<BODY BGCOLOR=#FFFFFF>
<!-- ImageReady Slices (new_sia_ticker3.gif) -->
<TABLE WIDTH=133 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD COLSPAN=3>
<IMG SRC="images/2003OS_01.gif" WIDTH=133
HEIGHT=53></TD>
</TR>
<TR>
<TD COLSPAN=3 background="images/2003OS_02.gif" WIDTH=133
HEIGHT=111 class="internet" valign="top" align="right">
<FONT FACE="Verdana, Geneva" SIZE="1">
<a id=ph1 name=ph1 TARGET="_new" class='internet'
href="http://www.sportsinteraction.com"><img
src="http://www.sportsinteraction.com/s.gif" border="0" height="70"
width="125"></a><br>
<a id=ph2 name=ph2 TARGET="_new" class='internet'
href="http://www.sportsinteraction.com"></a><br>
<a id=ph3 name=ph3 TARGET="_new" class='internet'
href="http://www.sportsinteraction.com"></a>
</font>
</td>
<td valign="bottom">
<A NAME="phb"><IMG ALT=""
SRC="http://www.sportsinteraction.com/pages/oddsscroller/t.gif" WIDTH="1"
HEIGHT="1" border=0></a>
</TD>
</TR>
<TR>
<TD COLSPAN=3>
<IMG SRC="images/2003OS_03.gif" WIDTH=133
HEIGHT=19></TD>
</TR>
<TR>
<TD ROWSPAN=2>
<IMG SRC="images/2003OS_04.gif" WIDTH=48
HEIGHT=17></TD>
<TD>
<A HREF=""><IMG SRC="images/2003OS_05.gif"
WIDTH="45" HEIGHT="11" border="0"></A></TD>
<TD ROWSPAN=2>
<IMG SRC="images/2003OS_06.gif" WIDTH=40
HEIGHT=17></TD>
</TR>
<TR>
<TD>
<IMG SRC="images/2003OS_07.gif" WIDTH=45
HEIGHT=6></TD>
</TR>
</TABLE>
<!-- End ImageReady Slices -->
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
NS4=(document.layers);
IE4=(document.all);
Clr=(parseInt(navigator.appVersion) > 4 )
isMac=(navigator.appVersion.indexOf("Mac")!=-1);
if(Clr||NS4||(IE4&&!isMac)){
with (document) {
write("<SCRIPT
SRC='http://test.sportsinteraction.com/pages/oddsscroller/ls2.js'>");
write("<\/SCRIPT>");
}}
with (document) {
write("<br>Navigator Version="+parseInt(navigator.appVersion))
}
</SCRIPT>
</BODY>
</HTML>
javascript:
with (document) {
write("<br>ls2.js loaded")
}
NS4=(document.layers);IE4=(document.all);Clr=(parseInt(navigator.appVersion)
> 4 )
isMac=(navigator.appVersion.indexOf("Mac")!=-1);
if(Clr||NS4||(IE4&&!isMac)){
finite=(maxLoops>0);
var styleObj=(IE4)?".style":"";
function getPH(phname){
pHA="";
for(i=0;i<document.anchors.length;i++){
theA=document.anchors[i];
if(theA.name==phname){pHA=theA;break}
}
return pHA //placeholding A
}
function getReal(xy){
if(IE4){
Pos=(xy=="x")?this.offsetLeft:this.offsetTop;
tmpEl=this.offsetParent;
while(tmpEl!=null){
Pos+=(xy=="x")?tmpEl.offsetLeft:tmpEl.offsetTop;
tmpEl=tmpEl.offsetParent;
}
}else{
Pos=eval("this."+xy);
}
return Pos;
}
pHT=(NS4)?getPH("ph1"):document.all.ph1;
if(pHT){
pHT.getReal=getReal;
var bnrLft=pHT.getReal("x")-1,bnrTop=pHT.getReal("y");
pHB=(NS4)?getPH("phb"):document.all.phb;
if(pHB){
pHB.getReal=getReal;
var bnrRit=pHB.getReal("x"),bnrBot=pHB.getReal("y");
var bnrWid=bnrRit-bnrLft,bnrHit=bnrBot-bnrTop;
function getObj(i){obj=eval("msg"+i+styleObj);return obj}
onload=startBnr;
function showMsg(n,show){
var theEl=getObj(n);theEl.visibility=(show)?"visible":"hidden";
}
function nextMsg(){
var fm=current;current=(fm==ar.length-1)?0:fm+1;
if(current==1)loopCount++;
if(finite&&(loopCount>=maxLoops))return;
scrollBnr(fm,current);
}
function moveUp(){
if(NS4){
fmEl.top-=increment;
if(toEl.top-increment<=toElTarget){
toEl.top=toElTarget;clearInterval(intervalID);fmEl.visibility="hidden";
timeoutID=setTimeout("nextMsg()",pause);
}else{
toEl.top-=increment;
}
}else{
fmEl.pixelTop-=increment;
if(toEl.pixelTop-increment<=toElTarget){
toEl.pixelTop=toElTarget;clearInterval(intervalID);fmEl.visibility="hidden";
timeoutID=setTimeout("nextMsg()",pause);
}else{
toEl.pixelTop-=increment;
}}}
function scrollBnr(fm,to){
fmEl=getObj(fm);toEl=getObj(to);
if(NS4){
toEl.top=fmEl.top+bnrHit;toElTarget=fmEl.top;
}else{
toEl.pixelTop=fmEl.pixelTop+bnrHit;toElTarget=fmEl.pixelTop;
}
showMsg(to,true);
intervalID=setInterval("moveUp()",interval);
}
function moveTo(lPos,tPos){this.style.pixelLeft=lPos;this.style.pixelTop=tPos;}
function makeIE(){
var text='<DIV ID="bnr" STYLE="position:absolute">';
for(var i=ar.length-1;i>=0;i--){
text+='<DIV ID="msg'+i+'" STYLE="position:absolute" class="internet"><\/DIV>';
}
text+='<\/DIV>';
document.body.insertAdjacentHTML("BeforeEnd",text);
with(bnr.style){
width=bnrWid;height=bnrHit;clip="rect(0 "+bnrWid+" "+bnrHit+" 0)";
backgroundColor=bannerColor;
}
bnr.moveTo=moveTo;bnr.moveTo(bnrLft,bnrTop)
for(i=0;i<ar.length;i++){
with(eval("msg"+i+".style")){
visibility="hidden";width=bnrWid-leftPadding;backgroundColor=bannerColor;
}
eval("msg"+i+".moveTo=moveTo");
eval("msg"+i+".moveTo(leftPadding,topPadding)");
}
}
function makeNS(){
bnr=new Layer(bnrWid);
with(bnr){
clip.right=bnrWid;clip.bottom=bnrHit;clip.height=90;
moveTo(bnrLft,bnrTop);visibility="show";
}
for(var i=0;i<ar.length;i++){
eval("msg"+i+"="+"new Layer(bnrWid-leftPadding, bnr)");
with(eval("msg"+i)) {
clip.bottom=bnrHit+90;
moveTo(leftPadding,topPadding);
}}}
function fillBnr(){
var theEl;
for(i=0;i<ar.length;i++){
theEl=eval("msg"+i);
newsStr=ar[newsCount][1];
newsStr="<p class=internet>"+newsStr+"</p>";
if(NS4){
with(theEl.document){write(newsStr);close();}
}else{theEl.innerHTML=newsStr;}
newsCount++;if(newsCount==ar.length)newsCount=0;
}}
function startBnr(){
ar=new Array();
if(!window.arURL)return;if(arURL.length==0)return;
if(arURL.length<numheadlines)numheadlines=arURL.length;
for(i=0;i<numheadlines;i++){ar[i]=new Array(prefix+arURL[i],arTXT[i]);}
newsCount=0;if(finite)loopCount=0;
(NS4)?makeNS():makeIE();
fillBnr();showMsg(0,true);current=0;
window.onresize=reDo;timeoutID=setTimeout("nextMsg()",pause);
}
function reDo(){window.location.reload();}
}}}
Cheers,
Drew.
Drew Shiel, Web Development, Sports Interaction
ashiel at sportsinteraction.com
http://www.sportsinteraction.com/
+353-1-2365701 (Direct Line)
More information about the thelist
mailing list