...

View Full Version : javascript - One letter appear at a time problem



johnmerlino
11-06-2009, 04:01 PM
Hey all,
Below is a script that forces text to appear letter by letter. The problem is I want the actual letters to be a link at the same time and I don't want to display the text in a form tag, which it currently is in now. Rather I would like to display it in an h1 tag. Problem is, despite still referencing "msgform" in the html as an id selector of an h1 element and changing the code "self.document.msgform.elements[0].value=outMsg;" to "document.getElementById("msgform").value=outMsg;", it generates no effect at all. So I'm not exactly sure what I'm doing wrong as I try to display it in an h1 element and also as a link. Any help is greatly appreciated!




<script language="javascript" type="text/javascript">

var outMsg = "";
var i = 0;
var lineNo = 1;
var timerDM=null;
var msg = " ";
function araVob() {
}
var ScreenLine = new araVob();
ScreenLine[1] = "Opportunities!"

var msgNum = 1;
var msgCnt = 1;
var typeSpeed = 70;
var pageLen = 1;
var delay=typeSpeed;
var r = 0;
var cr="\r\n"
if ("3" <=navigator.appVersion.charAt(0)) {
var cr="\n"
}
for (x = 1; x<=(msgCnt); x++) {
ScreenLine[x] = ScreenLine[x] + cr;
}
msg = ScreenLine[1];

function DisplayMsg() {
if (msg.length <= i || msg.charAt(i) == "\f") {
r=i;
i=0;
ChangeMsg();
}
outMsg = outMsg + msg.charAt(i);
i++;
if (msg.charAt(i) == "\f" || (lineNo == pageLen && i==msg.length)) {
delay = 4000; }
else {
if (msg.charAt(i) == cr && msg != " "+cr) {
delay = 2000; }
else {
delay = typeSpeed; }
}
self.document.msgform.elements[0].value=outMsg;
timerDM = setTimeout("DisplayMsg()",delay);
}

function ChangeMsg() {
msgNum++;
if (msgCnt < msgNum) {
msgNum = 1;
}
lineNo++;
if (pageLen < lineNo || msg.charAt(r) == "\f") {
outMsg=ScreenLine[msgNum].charAt(i);
i++;
lineNo = 1;
}
msg = ScreenLine[msgNum];
}

window.onload = DisplayMsg;
window.onunload = quitDisplay;
// -->
</script>
<FORM NAME= "msgform" ACTION=" " style="position:absolute;">
<TEXTAREA style="border:none;">
</TEXTAREA>

</FORM>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum