PDA

View Full Version : Typing text



chechu
11-06-2006, 01:56 PM
Dear all,

Is it possible to do the following with the code of typing text below:
- make the typing text align=justify
- place two typing texts on one page (without placing frames)
- using <br>, <b>, <u>, etc.

Code:

<script language="JavaScript1.2">
<!--
var line=new Array()
line[1]="text"
line[2]="text"

var longestmessage=1
for (i=2;i<line.length;i++){
if (line[i].length>line[longestmessage].length)
longestmessage=i
}

var tscroller_width=line[longestmessage].length

lines=line.length-1

if (document.all||document.getElementById){
document.write('<form name="bannerform">')
document.write('<Textarea name="banner" rows="20" cols="50"')
document.write(' class="bgscroller" onfocus="blur()"></textarea>')
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=temp;
temp="";
setTimeout("nextstep()",3000)}
else if (nextline==lines & temp==line[nextline] & temp.length==line[nextline].length){
nextline=1;
nextchar=-1;
document.bannerform.banner.value=temp;
temp="";
setTimeout("nextstep()",3000)}
else{
nextstep()}}

function nextstep(){

if (cursor=="\\"){
cursor="|"}
else if (cursor=="|"){
cursor="/"}
else if (cursor=="/"){
cursor="-"}
else if (cursor=="-"){
cursor="\\"}

nextchar++;
temp+=line[nextline].charAt(nextchar);
document.bannerform.banner.value=temp+cursor
setTimeout("animate()",25)}

if (document.all||document.getElementById)
window.onload=animate
// -->
</script>

codeexploiter
11-07-2006, 05:41 AM
How can this be a HTML question :)

jscheuer1
11-07-2006, 06:18 AM
How can this be a HTML question

It's not 'a HTML question' but, this DD script by Twey can be used for all that:

http://www.dynamicdrive.com/dynamicindex10/text5.htm

codeexploiter - DD can move the threads around as he sees fit, you don't have to make a post just to say that a person is in the wrong forum.

chechu
11-07-2006, 02:32 PM
http://www.dynamicdrive.com/dynamicindex10/text5.htm

This script shows two lines, but the text remains. Meaning is to place different messages one after another, and doing this twice on the same page (different languages). See it as a bilingual guestbook.

chechu
11-10-2006, 11:53 AM
Help ?

chechu
11-11-2006, 11:19 AM
Is the only sollution then placing the seond one in an <iframe> ?

jscheuer1
11-11-2006, 12:40 PM
With the script I gave you a link to, you can have as many 'typing texts' as you like on a page, anywhere you like on the page with any tags and formatting - all without iframe. Read the demo page thoroughly and you should see that this is the case.

chechu
11-11-2006, 01:00 PM
Yes, but after typing the text, it remains fixed. I would like it to get back to the first message when all messages have been typed, like in the script I posted. Is that possible with the DD script ?

Twey
11-11-2006, 01:55 PM
Yes, I built in callbacks for just such an emergency. One can quite easily do something like this:
<script type="text/javascript">
var messages = [
"Message One",
"Message Two",
"Message Three"
], next = -1, elm, tref;

function cursorFunc(i) {
var ar = new Array("\\", "|", "/", "-");
return " " + ar[i.length % ar.length];
}

window.onload = function() {
// Set the original variables
elm = document.getElementById("banner");
// And start the loop
tref = new TypingText(elm, 100, cursorFunc, nextMessage);
};

function nextMessage() {
// Set the message appropriately.
elm.innerHTML = messages[++next || next = 0];
// Rerun the constructor, but don't create a new object.
TypingText.apply(tref, elm, 100, cursorFunc, nextMessage);
};
</script>
<p id="banner"></p>Untested.