Bongeh Posted November 13, 2008 Share Posted November 13, 2008 Hi guys, Basically i've got a script that'll do a vertical marquee with no gap after the last item in the list, it uses an array for the items, but i need the items to have links. As you can see in the first item in the list ive tryed to trick the script, but it hasnt worked quite as id hoped. If i put a < or " in the field array then it stops the script working all together. Any ideas? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- saved from url=(0050)http://slayeroffice.com/code/vmarquee/marquee.html --> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=utf-8"> <STYLE type=text/css> .marquee { FONT-SIZE: 10px; WIDTH: 190px; COLOR: #1a2658; FONT-FAMILY: verdana; POSITION: absolute; TOP: 100px } BODY { BACKGROUND-COLOR: #ffffff } </STYLE> <SCRIPT langauge="javascript"> var marqueeText = new Array(); marqueeText[0] = "<a href="http://www.link.com">Text</a>"; marqueeText[1] = "This is v1 of the Vertical Scrolling Marquee."; marqueeText[2] = "These text strings are part of a javascript array."; marqueeText[3] = "They are dynamically set into the two scrolling DIVs' innerHTML." marqueeText[4] = "Based on the number of characters in the DIV, it approximates the height in pixels."; marqueeText[5] = "When one reaches negative itsHeight+100, the second DIV begins its accent."; marqueeText[6] = "When one reaches negative itsHeight, it goes back to the bottom and starts the process over."; marqueeText[7] = "Mousing over the objects will pause the scrolling, while mousing out starts it again."; marqueeText[8] = "Thats how its works - here comes the next div."; var currentMarquee = 1; var divHeight = 0; var nextScroll; var clearMe; var mInterval; var marquee_paused = false; function marquee_initMarquee() { mHTML = ""; for(i=0;i<marqueeText.length;i++)mHTML+= marqueeText[i] + "<p>"; document.getElementById("marquee1").innerHTML = mHTML; document.getElementById("marquee2").innerHTML = mHTML; divHeight = returnDivHeight(); // adjust these to suit your repeat document.all?adjustScroll = 100:adjustScroll = 175; nextScroll = 0 - (divHeight)+adjustScroll; clearMe = 0 - divHeight; mInterval = setInterval("marquee_beginScroll()",50); } function marquee_beginScroll() { if(!marquee_paused) { cur = "marquee" + currentMarquee; curTop = parseInt(document.getElementById(cur).style.top); curTop-=1; if(curTop<=nextScroll) { cur=="marquee1"?cur2 = "marquee2":cur2 = "marquee1"; curTop2 = parseInt(document.getElementById(cur2).style.top); curTop2-=1; document.getElementById(cur2).style.top = curTop2; } document.getElementById(cur).style.top = curTop; if(curTop<=clearMe) { document.getElementById(cur).style.top = 100; currentMarquee==1?currentMarquee=2:currentMarquee=1; } } } function returnDivHeight() { // assumes a max of 30 characters on one line at font-size:10px // <p> height at 35px, and total line height of 15px; lineLength = new Array(); totalLength = 0; for(i=0;i<marqueeText.length;i++) lineLength[lineLength.length] = marqueeText[i].length; for(i=0;i<lineLength.length;i++)totalLength+=(lineLength[i]+35); return Math.floor((totalLength/30)*15)+20; } </SCRIPT> <META content="MSHTML 6.00.6000.16735" name=GENERATOR></HEAD> <BODY onload=marquee_initMarquee();> <DIV class=marquee id=marquee1 onmouseover=marquee_paused=true; style="TOP: 100px" onmouseout=marquee_paused=false;></DIV> <DIV class=marquee id=marquee2 onmouseover=marquee_paused=true; style="TOP: 100px" onmouseout=marquee_paused=false;></DIV></BODY></HTML> Quote Link to comment Share on other sites More sharing options...
rhodesa Posted November 13, 2008 Share Posted November 13, 2008 shouldn't that line be: marqueeText[0] = '<a href="http://www.link.com">Text</a>'; Quote Link to comment Share on other sites More sharing options...
Bongeh Posted November 13, 2008 Author Share Posted November 13, 2008 if i do that, the script stops working Quote Link to comment Share on other sites More sharing options...
Bongeh Posted November 13, 2008 Author Share Posted November 13, 2008 ohh! i see, using ' instead of " to define the field Okay it works now!, thank you so much Quote Link to comment Share on other sites More sharing options...
rhodesa Posted November 13, 2008 Share Posted November 13, 2008 you could have also done: marqueeText[0] = "<a href=\"http://www.link.com\">Text</a>"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.