#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Posts
    421
    Rep Power
    12

    Javascript not working in netscape


    This code just goes through fading in and out text three different times then loops. It works in Internet Explorer but not in netscape (I tested netscape 6.2). Any ideas? I would greatly appreciate any help. Here is the code:

    <SCRIPT LANGUAGE="JavaScript">
    var qiksearch_js_text = new Array ("Welcome to the", "Village of Manlius", "Website!");
    var qiksearch_space_width = 260; // The width of the content space
    var qiksearch_space_height = 50; // The height of the content space
    var qiksearch_space_borderw=0; // Border width
    var qiksearch_space_borderc="#CC0000"; // Border Color
    var timeOutVal=80; // Delay in milliseconds
    document.write('<table width="' + qiksearch_space_width + '" height="' + qiksearch_space_height + '" style="background:#FFFFFF; border:' + qiksearch_space_borderw + ' solid ' + qiksearch_space_borderc + '"><tr><td align="middle">');
    document.write('<div id="qiksearch_js_space">');
    document.write('</div>');
    document.write('</td></tr></table>');
    var def_10='A',def_11='B',def_12='C',def_13='D',def_14='E',def_15='F';
    var colorVal=15;
    var div_count=0;
    function qiksearch_fade_desat(getColorIntVal)
    {
    var returnVal;
    if(getColorIntVal>=10)
    {
    for(var i=0; i<=15; i++)
    {
    if((getColorIntVal==i))
    {
    returnVal = eval('def_' + i);
    }
    }
    }
    else
    {
    returnVal=getColorIntVal;
    }
    return(returnVal);
    }
    function writeDiv()
    {
    document.all.qiksearch_js_space.innerHTML= '<font face="verdana,arial,helvetica" size="5" color="' + joinColor(qiksearch_fade_desat(colorVal)) + '"><b>' + qiksearch_js_text[div_count] + '</span></b></font>' ;
    if((colorVal>0) && (colorVal!=0))
    {
    colorVal--;
    }
    else
    {
    colorVal=15;
    if(div_count<qiksearch_js_text.length)
    {
    div_count++;
    }
    if(div_count==qiksearch_js_text.length)
    {
    div_count=0;
    }
    }
    if(div_count<qiksearch_js_text.length)
    {
    setTimeout("writeDiv()",timeOutVal);
    }
    }
    function joinColor(getColor)
    {
    return (getColor + '0' + getColor + '0' + getColor + '0');
    }
    function resetAll()
    {
    div_count=0;
    colorVal=15;
    }
    writeDiv();
    </script>


    Regards,
    Andy
    hmmm...
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2002
    Posts
    596
    Rep Power
    23
    document.all is IE only so change this line:

    document.all.qiksearch_js_space.innerHTML......

    to
    var t = document.getElementById('qiksearch_js_space');
    t.innerHTML...
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Posts
    421
    Rep Power
    12
    hmm..if I understood your correctly the code should look something like this:

    <SCRIPT LANGUAGE="JavaScript">
    var qiksearch_js_text = new Array ("Welcome to the", "Village of Manlius", "Website!");
    var qiksearch_space_width = 260; // The width of the content space
    var qiksearch_space_height = 50; // The height of the content space
    var qiksearch_space_borderw=0; // Border width
    var qiksearch_space_borderc="#CC0000"; // Border Color
    var timeOutVal=80; // Delay in milliseconds
    document.write('<table width="' + qiksearch_space_width + '" height="' + qiksearch_space_height + '" style="background:#FFFFFF; border:' +

    qiksearch_space_borderw + ' solid ' + qiksearch_space_borderc + '"><tr><td align="middle">');
    document.write('<div id="qiksearch_js_space">');
    document.write('</div>');
    document.write('</td></tr></table>');
    var def_10='A',def_11='B',def_12='C',def_13='D',def_14='E',def_15='F';
    var colorVal=15;
    var div_count=0;
    function qiksearch_fade_desat(getColorIntVal)
    {
    var returnVal;
    if(getColorIntVal>=10)
    {
    for(var i=0; i<=15; i++)
    {
    if((getColorIntVal==i))
    {
    returnVal = eval('def_' + i);
    }
    }
    }
    else
    {
    returnVal=getColorIntVal;
    }
    return(returnVal);
    }
    function writeDiv()
    {
    var t = document.getElementById('qiksearch_js_space');
    t.innerHTML = '<font face="verdana,arial,helvetica" size="5" color="' + joinColor(qiksearch_fade_desat(colorVal)) + '"><b>' +

    qiksearch_js_text[div_count] + '</span></b></font>' ;
    if((colorVal>0) && (colorVal!=0))
    {
    colorVal--;
    }
    else
    {
    colorVal=15;
    if(div_count<qiksearch_js_text.length)
    {
    div_count++;
    }
    if(div_count==qiksearch_js_text.length)
    {
    div_count=0;
    }
    }
    if(div_count<qiksearch_js_text.length)
    {
    setTimeout("writeDiv()",timeOutVal);
    }
    }
    function joinColor(getColor)
    {
    return (getColor + '0' + getColor + '0' + getColor + '0');
    }
    function resetAll()
    {
    div_count=0;
    colorVal=15;
    }
    writeDiv();
    </script>


    Which doesn't work in netscape. Am I following your directions properly? Thanks.
    -andy
    hmmm...
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2002
    Posts
    596
    Rep Power
    23
    in the function writeDiv try replacing all references to qiksearch_js_text with t (after the line where you use getElementById)
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Netherlands
    Posts
    99
    Rep Power
    12
    in the function writeDiv try replacing all references to qiksearch_js_text with t (after the line where you use getElementById)
    That will not work since t is a reference to the DIV and qiksearch_js_text is the name of the Array

    You followed the directions correctly but you probably have this piece of script in the head-section of your HTML-document.
    What you can do to make it work is to remove the line where call your writeDiv()-function to the bottom of your page:

    i.e.:

    <html>
    <head>
    <title>Test!</title>
    <SCRIPT LANGUAGE="JavaScript">
    .... the piece of code you have but without the call to writeDiv() on the last line ....
    </script>
    </head>
    <body>

    <script language="JavaScript1.2">
    writeDiv();
    </script>

    </body>
    </html>


    That should do the trick!
    Last edited by DeepDown; July 30th, 2003 at 04:49 AM.
    ** Don't expect me to code your needs, but if I am able to help, I'm willing. Shout, grab and use the hand!
    ** Man can no more own the land we walk upon, as they can lay claim on the air that we breath
    ** DeepDown I'm addicted to structures.... ohw and music
    ** Almost forgot I had an account here [*o*]
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2002
    Posts
    596
    Rep Power
    23
    That will not work since t is a reference to the DIV and qiksearch_js_text is the name of the Array
    whoops, more coffee needed...
  12. #7
  13. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Posts
    421
    Rep Power
    12
    Thanks man! besides the fact that it doesn't fade in and out like in IE is fine. If there is a way to make it fade in and out in netscape and IE I would love to know, but for now thanks a bunch.

    -andy
    hmmm...
  14. #8
  15. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Posts
    421
    Rep Power
    12
    oops.. now when I put it in a table when I call the function no matter what the javascript gets put on the uppler left hand of the screen in IE and Netscape. I can't position it anywhere. Example:

    http://www.villageofmanlius.org/here.html

    This is where it is supposed to be

    http://www.villageofmanlius.org
    hmmm...
  16. #9
  17. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Posts
    421
    Rep Power
    12
    anyone?
    hmmm...
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Netherlands
    Posts
    99
    Rep Power
    12
    use a function to animate and load the div with that id in the document instead of using document.write()???
    ** Don't expect me to code your needs, but if I am able to help, I'm willing. Shout, grab and use the hand!
    ** Man can no more own the land we walk upon, as they can lay claim on the air that we breath
    ** DeepDown I'm addicted to structures.... ohw and music
    ** Almost forgot I had an account here [*o*]

IMN logo majestic logo threadwatch logo seochat tools logo