Results 1 to 9 of 9

Thread: Typing text

  1. #1
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    917
    Thanks
    120
    Thanked 2 Times in 2 Posts

    Default Typing text

    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>

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    How can this be a HTML question

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by codeexploiter
    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    917
    Thanks
    120
    Thanked 2 Times in 2 Posts

    Default

    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.

  5. #5
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    917
    Thanks
    120
    Thanked 2 Times in 2 Posts

    Default

    Help ?

  6. #6
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    917
    Thanks
    120
    Thanked 2 Times in 2 Posts

    Default

    Is the only sollution then placing the seond one in an <iframe> ?

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    917
    Thanks
    120
    Thanked 2 Times in 2 Posts

    Default

    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 ?

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yes, I built in callbacks for just such an emergency. One can quite easily do something like this:
    Code:
    <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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •