Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    Setting in a tall corn field in Indiana
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with <table> formatting within a variable

    I have a script that I am using to dynamically change the displayed text on a page. I have no problem with the script working correctly in IE, but NS4+ does not see the <table> formatting within the "var" (lines 21-23) . this causes my document.write (line 40) to be "undefined/empty".

    Is there some trick to getting NS to see this formatting?

    Any help would be appreciated.

    ========================== Code ==========================
    <html>
    <head>

    <title>Timer</title>

    <!-- Styles for text displayed in the countdown -->
    <style type="text/css">
    .countText, .countTextRed, .stopCountText {font-family:arial,helvetica}
    .countText {font-size:20px; color:black; font-weight:bold}
    .countTextRed {font-size:20px; color:red; font-weight:bold}
    .stopCountText {font-size:30px; color:blue; font-weight:bolder}
    </style>

    <script language=javascript>

    // Variables Used in Functions
    var countdownStart=15; // Total Time (in seconds) for message to cycle thru the display
    var textActionCount=1; // Should have the same number as the first "textAction" array below
    var fileName="filename";

    var countdownStartTxt1='<table width="100%"><tr><td width="70%" align="right"><span class="countText">Please Be Patient Creating The File: <span class="countTextRed">'; // Text Line1 To Display When Countdown Has Completed
    var countdownStartTxt2='</tr></table>'; // Text line2 To Display When Countdown Has Completed
    var countdownStop='<table width="100%"><tr><td align="middle"><span class="stopCountText">File Creation Has Completed !!!</span></td></tr></table>'; // Text To Display When Countdown Has Completed

    // Array of text that will be dynamically changed in the document
    var textAction=new Array()
    textAction[1]='</span></td><td align="left"><span class="countText">.</span></td>'
    textAction[2]='</span></td><td align="left"><span class="countText">..</span></td>'
    textAction[3]='</span></td><td align="left"><span class="countText">...</span></td>'
    textAction[4]='</span></td><td align="left"><span class="countText">....</span></td>'
    textAction[5]='</span></td><td align="left"><span class="countText">.....</span></td>'

    function getCountDown()
    {
    counttime=countdownStart--; // subtracting 1 from countdownStart timer number
    textCount=textActionCount++; // adding 1 to testAction array number

    // Countdown Text Will Be Displayed On A "Layer" In The Page
    if (document.layers){
    document.layers.countdown.document.write(countdownStartTxt1+fileName+textAction[textCount]+countdownStartTxt2);
    document.layers.countdown.document.close();
    }
    else if (document.all){
    countdown.innerHTML=countdownStartTxt1+fileName+textAction[textCount]+countdownStartTxt2;
    }
    else if (document.getElementById){
    document.getElementById("countdown").innerHTML=countdownStartTxt1+fileName+textAction[textCount]+countdownStartTxt2;
    }

    // Reseting the text count after array has completed
    // Please Note:
    // If you add/remove entries in the array above you should also
    // change this reset as well to the same total number
    if (textCount>=5){
    textActionCount=1
    }

    // Stop Countdown when it reaches 0
    if (countdownStart>=0) window.setTimeout('getCountDown()',1000); // "1000"(in milliseconds) = speed at which text changes

    // Display Below Text When Countdown is Complete
    else {
    if (document.layers){
    document.layers.countdown.document.write(countdownStop);
    document.layers.countdown.document.close();
    }
    else if (document.all)
    countdown.innerHTML=countdownStop;
    else if (document.getElementById)
    document.getElementById("countdown").innerHTML=countdownStop;
    }
    }
    </script>
    </head>

    <!-- <body onLoad="window.setTimeout('getCountDown()',1)"> -->
    <body onLoad='getCountDown()'>

    <!-- Text Will Be Displayed On A "Layer" In The Page -->
    <div id="countdown"></div>

    </body>
    </html>

    =================================================

  • #2
    New Coder
    Join Date
    Aug 2002
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Don't know if this will help or not but you have a space before the "write(" portion of line 49. (Same thing on line 49.) I don't have NS4.x to test it with...

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    I don't think that's the problem. This forum just messed that up.

    If you follow this line:

    document.layers.countdown.document.write(countdownStartTxt1 + fileName + textAction[textC
    ount] + countdownStartTxt2);

    the output would be:

    Code:
    <table width="100%"><tr>
    <td width="70%" align="right">
      <span class="countText">Please Be Patient Creating The File: 
         <span class="countTextRed">
            filename
        </span>
      <!--no closing span tag here!!!-->
    </td><td align="left"><span class="countText">.</span></td>
    </tr></table>
    As you can notice there's no closing span tag for the first span.
    So to fix that, you should add another closing span tag in textAction array:

    textAction[1]='</span></span></td><td align="left"><span class="countText">.</span></td>'
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    New Coder
    Join Date
    Oct 2002
    Location
    Setting in a tall corn field in Indiana
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts
    glenngv,

    I added the additional </span> that was needed but I still get the same javascript error from NS.


    "line 40: document.layers.countdown has no properties."

    Any other suggestions?

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Since you're talking Netscape 4 you need to be aware that NS4 requires any object that you want to turn into a layer to be declared using the <layer> or <ilayer> tags or a <div> or <span> tags but when using <div> or <span> those tags also require you to declare them as "position: absolute" or "position: relative" in order for them to become layers. I this case you need to add the appropriate "position" style at which point you'll find out that the text is no longer in your table cell and you've also got a lot of work to do in order to get it back there.
    Check out the Forum Search. It's the short path to getting great results from this forum.


  •  

    Posting Permissions

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