<DIV>tag in netscape? but works in IE (see code)

Discussion in 'Javascript' started by D E, Jun 21, 2004.

  1. D E

    D E Guest

    Here is the problem. The following script/html code works in IE, not
    Netscape. The javascript portion produces the text to be dynamically written
    in the
    <A HREF="">HEREHEREHERE</A> portion...
    The HEREHEREHEREHERE writes fine in internet explorer, but does not appear
    at all in Netscape 7.1. I think it might have something to do with layers...
    How do I correct this? Thanks.


    -----------------------JAVASCRIPT PORTION:----------------------------------
    <SCRIPT LANGUAGE="JAVASCRIPT" TYPE="text/javascript">
    <!---
    function produceEnter() {
    //produces a random number between 1 and 8
    intInt = Math.round(Math.random() * 7 + 1);

    switch(intInt) {
    case 1: //Spanish
    langString = "[ENTRE](spanish)";
    break;
    case 2: //French
    langString = "[ENTRER](french)";
    break;
    case 3: //German
    langString = "[TRAGEN SIE EIN](german)";
    break;
    case 4: //Italian
    langString = "[ENTRARE](italian)";
    break;
    case 5: //Dutch
    langString = "[GA BINNEN](dutch)";
    break;
    case 6: //Portuguese
    langString = "[ENTRE](portuguese)";
    break;
    case 7: //English
    langString = "[ENTER](english)";
    break;
    case 8: //Norwegian
    langString = "[GÅ INN I](norwegian)";
    break;
    default: //English
    langString = "[ENTER](english)";
    break;
    }
    Enter.innerHTML = langString;

    }
    --->
    </SCRIPT>
    -----------------------------HTML PORTION-----------------------
    <TABLE BACKGROUND="images/opener-waterfall.gif" ALIGN="CENTER"
    VALIGN="CENTER" BORDER="0" CELLPADDING="0" CELLSPACING="0">
    <TR>
    <TD>

    <TABLE BACKGROUND="none.gif" ALIGN="CENTER" VALIGN="CENTER">
    <TR>
    <TD CLASS="centerTD"><A HREF="index2.html"><DIV
    ID="Enter"></DIV></A></TD>
    </TR>
    </TABLE>

    </TD>
    </TR>
    </TABLE>

    -----------------------------END CODE-------------------
     
    D E, Jun 21, 2004
    #1
    1. Advertising

  2. D E

    DU Guest

    D E wrote:
    > Here is the problem. The following script/html code works in IE, not
    > Netscape. The javascript portion produces the text to be dynamically written
    > in the
    > <A HREF="">HEREHEREHERE</A> portion...
    > The HEREHEREHEREHERE writes fine in internet explorer, but does not appear
    > at all in Netscape 7.1. I think it might have something to do with layers...
    > How do I correct this? Thanks.
    >
    >
    > -----------------------JAVASCRIPT PORTION:----------------------------------
    > <SCRIPT LANGUAGE="JAVASCRIPT" TYPE="text/javascript">


    Language is deprecated; type has superseded language and is both
    backward and forward compatible.

    > <!---


    Commenting out script code is unneeded unless you're looking to support
    *very* old browsers.

    > function produceEnter() {
    > //produces a random number between 1 and 8
    > intInt = Math.round(Math.random() * 7 + 1);
    >
    > switch(intInt) {
    > case 1: //Spanish
    > langString = "[ENTRE](spanish)";
    > break;
    > case 2: //French
    > langString = "[ENTRER](french)";
    > break;
    > case 3: //German
    > langString = "[TRAGEN SIE EIN](german)";
    > break;
    > case 4: //Italian
    > langString = "[ENTRARE](italian)";
    > break;
    > case 5: //Dutch
    > langString = "[GA BINNEN](dutch)";
    > break;
    > case 6: //Portuguese
    > langString = "[ENTRE](portuguese)";
    > break;
    > case 7: //English
    > langString = "[ENTER](english)";
    > break;
    > case 8: //Norwegian
    > langString = "[GÅ INN I](norwegian)";
    > break;
    > default: //English
    > langString = "[ENTER](english)";
    > break;
    > }
    > Enter.innerHTML = langString;
    >



    document.getElementById("Enter").childNodes[0].nodeValue = langString;

    will work in MSIE 5+, NS 6.2, NS 7.x, Mozilla-based browsers, Konqueror
    3.x, Safari 1.x, etc..

    > }
    > --->
    > </SCRIPT>
    > -----------------------------HTML PORTION-----------------------
    > <TABLE BACKGROUND="images/opener-waterfall.gif" ALIGN="CENTER"
    > VALIGN="CENTER" BORDER="0" CELLPADDING="0" CELLSPACING="0">
    > <TR>
    > <TD>
    >
    > <TABLE BACKGROUND="none.gif" ALIGN="CENTER" VALIGN="CENTER">


    No need for a nested table here. You just make the markup code more
    complex, longer to parse, load and render.

    > <TR>
    > <TD CLASS="centerTD"><A HREF="index2.html"><DIV
    > ID="Enter"></DIV>


    Improper nesting. You can not have a block-level element within an
    inline element.

    <a href="index2.html" id="idLangString"></a>

    and then

    document.getElementById("idLangString").childNodes[0].nodeValue =
    langString;

    will work again in will work in MSIE 5+, NS 6.2, NS 7.x, Mozilla-based
    browsers, Konqueror 3.x, Safari 1.x, etc.. and in other W3C compliant
    browsers.

    You have many web design and markup syntax problems to deal with in that
    code. None of your tables seems justified since you don't have tabular
    data to render in the first place.

    DU

    </A></TD>
    > </TR>
    > </TABLE>
    >
    > </TD>
    > </TR>
    > </TABLE>
    >
    > -----------------------------END CODE-------------------
    >
    >
     
    DU, Jun 21, 2004
    #2
    1. Advertising

  3. D E

    Lee Guest

    D E said:


    > //produces a random number between 1 and 8
    > intInt = Math.round(Math.random() * 7 + 1);


    In addition to the other problems that have been
    pointed out, this line returns 1 and 8 only half
    as often as any of the other values.
    The correct code is:

    intInt = Math.floor(Math.random()*8+1);
     
    Lee, Jun 21, 2004
    #3
  4. D E

    Mick White Guest

    Lee wrote:

    > D E said:
    >
    >
    >
    >>//produces a random number between 1 and 8
    >>intInt = Math.round(Math.random() * 7 + 1);

    >
    >
    > In addition to the other problems that have been
    > pointed out, this line returns 1 and 8 only half
    > as often as any of the other values.


    Quite right, a simple check would demonstrate this.

    http://www.mickweb.com/demo/notRandom.html

    Mick

    > The correct code is:
    >
    > intInt = Math.floor(Math.random()*8+1);
    >
     
    Mick White, Jun 21, 2004
    #4
  5. JRS: In article <>, seen in
    news:comp.lang.javascript, Lee <> posted at Mon,
    21 Jun 2004 06:35:48 :
    >D E said:
    >
    >> //produces a random number between 1 and 8
    >> intInt = Math.round(Math.random() * 7 + 1);

    >
    >In addition to the other problems that have been
    >pointed out, this line returns 1 and 8 only half
    >as often as any of the other values.
    >The correct code is:
    >
    > intInt = Math.floor(Math.random()*8+1);



    It would be useful to refer to the FAQ. Your answer of course covers
    the current point; but who knows what else the OP might learn from
    reading the FAQ? BTW, your solution does not address the bug in Opera.

    The OP cross-posted excessively; therefore I do not see more than his
    header, nor that of DU's reply. Cross-posting to more than two or three
    groups can diminish readership.

    <FAQENTRY> In section 4.22, "between" should be "in the range" or
    similar. Between 1 & 3 there is only 2.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://jibbering.com/faq/> JL / RC : FAQ for news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
     
    Dr John Stockton, Jun 21, 2004
    #5
  6. D E

    Lee Guest

    Dr John Stockton said:
    >
    >JRS: In article <>, seen in
    >news:comp.lang.javascript, Lee <> posted at Mon,
    >21 Jun 2004 06:35:48 :
    >>D E said:
    >>
    >>> //produces a random number between 1 and 8
    >>> intInt = Math.round(Math.random() * 7 + 1);

    >>
    >>In addition to the other problems that have been
    >>pointed out, this line returns 1 and 8 only half
    >>as often as any of the other values.
    >>The correct code is:
    >>
    >> intInt = Math.floor(Math.random()*8+1);

    >
    >
    >It would be useful to refer to the FAQ. Your answer of course covers
    >the current point; but who knows what else the OP might learn from
    >reading the FAQ? BTW, your solution does not address the bug in Opera.


    I had intended to point to the FAQ. That was an oversight.
    I'm torn on the Opera bug, leaning towards letting it fail.
    Of course, nobody who uses my production code uses Opera.
     
    Lee, Jun 22, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shruds
    Replies:
    1
    Views:
    939
    John C. Bollinger
    Jan 27, 2006
  2. D E
    Replies:
    1
    Views:
    1,382
  3. Eqbal Z
    Replies:
    6
    Views:
    204
    Eqbal Z
    Aug 27, 2003
  4. M Wells
    Replies:
    0
    Views:
    149
    M Wells
    Oct 6, 2004
  5. visu
    Replies:
    4
    Views:
    325
Loading...

Share This Page