...

View Full Version : Please Help, Adding URL Link to Javascript (Easy Answer)



ukd
10-23-2006, 07:18 PM
Hi, i've got this script which is a scrolling news ticker. It works 100% great, apart from the fact that i can't link the text to a url on my site. Can anybody help me here please, i'm sure it is a simple easy answer. Many thanks.

OK So the News Ticker came in 2 files. One Javascript and one HTML. I believe it needs to be added to the Javascript file somewhere. Adding it where it says Link? does not work. Here is the Javascript code:

var titlea = new Array();var texta = new Array();var linka = new Array();var trgfrma = new Array();var heightarr = new Array();var cyposarr = new Array();
cyposarr[0]=0;cyposarr[1]=1;cyposarr[2]=2;cyposarr[3]=3;
titlea[0] = "ARTICLE TITLE 1";texta[0] = "MY FIRST ARTICLE TEXT";linka[0] = "LINK?";trgfrma[0] = "_top";titlea[1] = "ARTICLE TITLE 2";texta[1] = "ARTICLE TEXT 2";linka[1] = "LINK?";trgfrma[1] = "_top";titlea[2] = "ARTICLE TITLE 3";texta[2] = "ARTICLE TEXT 3";linka[2] = "/cricket/icc.html";trgfrma[2] = "_top";titlea[3] = "ARTICLE TITLE 4";texta[3] = "ARTICLE TEXT 4";linka[3] = "/albums/chalakiyan.html";trgfrma[3] = "_top";
var mc=4;

var inoout=false;

var tmpv;
tmpv=120-8-8-2*parseInt(1);
var cvar=0,say=0,tpos=0,enson=0,hidsay=0,hidson=0;

var psy = new Array();
divtextb ="<div id=d";
divtev1=" onmouseover=\"mdivmo(";
divtev2=")\" onmouseout =\"restime(";
divtev3=")\" ";
divtev4="";
divtexts = " style=\"position:absolute;visibility:hidden;width:"+tmpv+"; COLOR: #FFFFFF; left:0; top:0; FONT-FAMILY: MS Sans Serif,arial,helvetica; FONT-SIZE: 8pt; FONT-STYLE: normal; FONT-WEIGHT: normal; TEXT-DECORATION: none; margin:0px; overflow-x:hidden; LINE-HEIGHT: 12pt; text-align:left;padding:0px; cursor:'default';\">";
ie6span= " style=\"position:relative; COLOR: #FF0000; width:"+tmpv+"; FONT-FAMILY: verdana,arial,helvetica; FONT-SIZE: 9pt; FONT-STYLE: normal; FONT-WEIGHT: bold; TEXT-DECORATION: none; LINE-HEIGHT: 14pt; text-align:left;padding:0px;\"";

uzun="<div id=\"enuzun\" style=\"position:absolute;left:0;top:0;\">";
var uzunobj=null;
var uzuntop=0;
var toplay=0;



function mdivmo(gnum)
{
inoout=true;

if((linka[gnum].length)>2)
{


objd.style.color="#8E0606";
objd2.style.color="#B90000";

objd.style.cursor='hand';
objd2.style.cursor='hand';

objd.style.textDecoration='underline';objd2.style.textDecoration='underline';

}


}

function restime(gnum2)
{
inoout=false;
objd=eval("d"+gnum2);
objd2=eval("hgd"+gnum2);

objd.style.color="#FFFFFF";
objd2.style.color="#FF0000";

objd.style.textDecoration='none';objd2.style.textDecoration='none';

window.status="";

}

function butclick(gnum3)
{
//buildergenlink


}

function dotrans()
{
if(inoout==false){
uzuntop--;
if(uzuntop<(-1*toplay))
{
uzuntop=200;
}

enuzun.style.pixelTop=uzuntop;
}
if(psy[(uzuntop*(-1))+4]==3)
{
setTimeout('dotrans()',3000+35);
}
else{setTimeout('dotrans()',35);}

}

function initte2()
{
for(i=0;i<mc;i++)
{
objd=eval("d"+i);
if(parseInt(objd.offsetHeight)<=0){setTimeout('initte2()',1000);return;}
}
i=0;
for(i=0;i<mc;i++)
{
objd=eval("d"+i);
heightarr[i]=parseInt(objd.offsetHeight);
}

toplay=4;
for(i=0;i<mc;i++)
{
objd=eval("d"+i);
objd.style.visibility="visible";
objd.style.pixelTop=toplay;
psy[toplay]=3;
toplay=toplay+heightarr[i]+10;

}


enuzun.style.left=8+"px";
enuzun.style.height=toplay+"px";
enuzun.style.width=tmpv+"px";
uzuntop=200;



dotrans();

}

function initte()
{
i=0;
innertxt=""+uzun;
for(i=0;i<mc;i++)
{
innertxt=innertxt+""+divtextb+""+i+""+divtev1+i+divtev2+i+divtev3+i+divtev4+divtexts+"<span id=\"hgd"+i+"\""+ie6span+">"+titlea[i]+"</span><br>"+texta[i]+"</div>";
}
innertxt=innertxt+"</div>";

spageie.innerHTML=""+innertxt;
setTimeout('initte2()',500);

}




window.onload=initte;

Here is the HTML code in the other file if required:

<html><head><title></title></head><body bgcolor="#000000">
<script language="javascript">var OPB=false;uagent = window.navigator.userAgent.toLowerCase();OPB=(uagent.indexOf('opera') != -1)?true:false;if((document.all)&&(OPB==false)){document.write("<scr"+"ipt language=\"javascript\" sr"+"c=\"scroller_newsticie.js\"></scr"+"ipt>");}else{if(OPB==true){document.write("<div id=\"spagens\" style=\"position:absolute; width:120; height:200; left:0; top:0; border-style:solid; border-width:1px; border-color:#FFFF00;overflow:hidden;clip:rect(4 120 195 0);\"></div>");}else{document.write("<div id=\"spagensbrd\" style=\"position:absolute; width:118; height:198; left:0; top:0; border-style:solid; border-width:1px; border-color:#FFFF00;overflow:hidden;\"><div id=\"spagens\" style=\"position:absolute; width:118; height:198; left:0; top:0; border-width:0px; overflow:hidden;clip:rect(4 120 195 0);\"></div></div>");}document.write("<scr"+"ipt language=\"javascript\" sr"+"c=\"scroller_newsticns6.js\"></scr"+"ipt>");}</script>
<div id="disspageie" style="position:absolute;background:#000000;width:120; height:200;left:0; top:0;margin:0px;overflow:hidden;padding:0px;border-style:solid; border-width:1px; border-color:#FFFF00;background-image: url(120x200.gif); background-repeat :no-repeat;background-position:0px 0px;">
<div id="spageie" style="position:absolute; width:120; height:200; left:0; top:0; border-width:0px; overflow:hidden;clip:rect(4 120 195 0);"></div>
</div>
</body></html>

ukd
10-29-2006, 07:37 PM
can nobody help me out here I know the code looks long, but i'm sure it is an easy answer?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum