PDA

View Full Version : Add HTML to Message Array & AutoScroll


actionscripter
01-16-2008, 09:54 PM
Hello,

I am trying to be able to create href links within the messages from this message array.

I am also trying to create an automatic scroll down effect which should be almost working.

I'm unsure of how to call the mainArea function to initiate the scrolling? I would assume to use the bodyonload but I am already calling another function through bodyonload.

Here is my current code. Any help is greatly greatly appreciated.



<html>

<head>




<title>Quotes</title>


<script type="text/javascript">
var quote = new Array();
quote[0] = "message this is to take up more than one line for testing

scrollup capability";
quote[1] = "message this is to take up more than one line for testing

scrollup capability";
quote[2] = "message this is to take up more than one line for testing

scrollup capability";
quote[3] = "message this is to take up more than one line for testing

scrollup capability";
quote[4] = "message this is to take up more than one line for testing

scrollup capability";
quote[5] = "message this is to take up more than one line for testing

scrollup capability";
var qno = 0;

function addMsg() {
obj = document.getElementById("divQuote");
txt = document.createTextNode(quote[qno]);
obj.appendChild(txt);
obj.appendChild(document.createElement("BR"));
qno++;
if (qno < quote.length)
{setTimeout("addMsg()", 5000);}
}

function populate() {
setTimeout("addMsg()", 1000);
}


</script>
<script>
function scrollMainArea()
{
document.getElementById("mainArea").scrollTop=0;
}
</script>
</head>

<body onload="populate()">

<div

id="mainArea"style="height:50px;overflow:auto; border:1px solid

black;">

<div id="divQuote"></div>

</div>

</body>
</html>

shyam
01-17-2008, 03:23 AM
intead of creating text nodes you could create divs and set the innerHTML property