azyet24
asked on
Hyperlink within array
I have a javascript that displays information like a ticker. I would like to hyperlink the text but I can't get it to work. Please help!
here's the var line:
var line=new Array()
line[1]="line 1 info"
line[2]="line 2 info"
I've tried
line[1]="<a href=""/index"">" & "line 1 info" & "</a>"
This didn't work though.
here's the var line:
var line=new Array()
line[1]="line 1 info"
line[2]="line 2 info"
I've tried
line[1]="<a href=""/index"">" & "line 1 info" & "</a>"
This didn't work though.
ASKER
Thanks for your help, but that didn't work. It just printed out what you wrote instead of using the html behind it. Maybe the entire code will help:
<script language="JavaScript1.2">
<!--
/*
Typing Scroller
Submitted by bengaliboy00@hotmail.com (hp: http://www.angelfire.com/nt/bengaliboy/)
With modifications by Dynamicdrive.com
For full source code, usage terms, and 100s more scripts, visit http://dynamicdrive.com
*/
//Secify scroller contents
var line=new Array()
line[1]="This is an awsome script"
line[2]="It brings up the text you want..."
line[3]="One letter at a time"
line[4]="You can add and subtract lines as you like."
line[5]="It\'s very cool and easy to use"
//Specify font size for scoller
var ts_fontsize="12px"
//--Don't edit below this line
var longestmessage=1
for (i=2;i<line.length;i++){
if (line[i].length>line[longe stmessage] .length)
longestmessage=i
}
//Auto set scroller width
var tscroller_width=line[longe stmessage] .length
lines=line.length-1 //--Number of lines
//if IE 4+ or NS6
if (document.all||document.ge tElementBy Id){
document.write('<form name="bannerform">')
document.write('<input type="text" name="banner" size="'+tscroller_width+'" ')
document.write(' style="background-color:#3 33333; color:white; font-family: verdana; font-size: '+ts_fontsize+'; font-weight:bold; border: medium none" onfocus="blur()">')
document.write('</form>')
}
temp=""
nextchar=-1;
nextline=1;
cursor="_"
function animate(){
if (temp==line[nextline] & temp.length==line[nextline ].length & nextline!=lines){
nextline++;
nextchar=-1;
document.bannerform.banner .value=tem p;
temp="";
setTimeout("nextstep()",20 00)}
else if (nextline==lines & temp==line[nextline] & temp.length==line[nextline ].length){
nextline=1;
nextchar=-1;
document.bannerform.banner .value=tem p;
temp="";
setTimeout("nextstep()",20 00)}
else{
nextstep()}}
function nextstep(){
if (cursor=="_"){
cursor="_"}
else if (cursor=="_"){
cursor="_"}
else if (cursor=="_"){
cursor="_"}
else if (cursor=="_"){
cursor="_"}
nextchar++;
temp+=line[nextline].charA t(nextchar );
document.bannerform.banner .value=tem p+cursor
setTimeout("animate()",50) }
//if IE 4+ or NS6
if (document.all||document.ge tElementBy Id)
window.onload=animate
// -->
</script>
<script language="JavaScript1.2">
<!--
/*
Typing Scroller
Submitted by bengaliboy00@hotmail.com (hp: http://www.angelfire.com/nt/bengaliboy/)
With modifications by Dynamicdrive.com
For full source code, usage terms, and 100s more scripts, visit http://dynamicdrive.com
*/
//Secify scroller contents
var line=new Array()
line[1]="This is an awsome script"
line[2]="It brings up the text you want..."
line[3]="One letter at a time"
line[4]="You can add and subtract lines as you like."
line[5]="It\'s very cool and easy to use"
//Specify font size for scoller
var ts_fontsize="12px"
//--Don't edit below this line
var longestmessage=1
for (i=2;i<line.length;i++){
if (line[i].length>line[longe
longestmessage=i
}
//Auto set scroller width
var tscroller_width=line[longe
lines=line.length-1 //--Number of lines
//if IE 4+ or NS6
if (document.all||document.ge
document.write('<form name="bannerform">')
document.write('<input type="text" name="banner" size="'+tscroller_width+'"
document.write(' style="background-color:#3
document.write('</form>')
}
temp=""
nextchar=-1;
nextline=1;
cursor="_"
function animate(){
if (temp==line[nextline] & temp.length==line[nextline
nextline++;
nextchar=-1;
document.bannerform.banner
temp="";
setTimeout("nextstep()",20
else if (nextline==lines & temp==line[nextline] & temp.length==line[nextline
nextline=1;
nextchar=-1;
document.bannerform.banner
temp="";
setTimeout("nextstep()",20
else{
nextstep()}}
function nextstep(){
if (cursor=="_"){
cursor="_"}
else if (cursor=="_"){
cursor="_"}
else if (cursor=="_"){
cursor="_"}
else if (cursor=="_"){
cursor="_"}
nextchar++;
temp+=line[nextline].charA
document.bannerform.banner
setTimeout("animate()",50)
//if IE 4+ or NS6
if (document.all||document.ge
window.onload=animate
// -->
</script>
I just took a cursory overlook of your code since I'm in class right now (-_-) but it seems that the Javascript is using a form field. Form fields, of course, cannot display HTML. Instead, you need a script that manipulates the DOM or at the very least uses innerHTML somehow. I would recommend checking out http://www.dynamicdrive.com/ as they have many well-made DHTML scripts that allow HTML as input.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
AtanAsfaloth,
That's awsome! thanks for your help, that's exactly what I needed.
That's awsome! thanks for your help, that's exactly what I needed.
line[1] = '<a href="/index">line 1 info</a>';
Javascript first of all uses +, not & as the concatenation operator and does not use VB standards of extra quotes. Instead, once you run out of single/double quotes, you need to escape quotes with the backslash.