Jump to content

[SOLVED] Inserting a link in a field for an array


Bongeh

Recommended Posts

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] = "&#60;a href&#61;&#34;http://www.link.com&#34;&#62;Text&#60;&#47;a&#62;";
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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.