By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,330 Members | 1,125 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,330 IT Pros & Developers. It's quick & easy.

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

P: n/a
D E
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-------------------
Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies

P: n/a
DU
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-------------------

Jul 23 '05 #2

P: n/a
Lee
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);

Jul 23 '05 #3

P: n/a
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);

Jul 23 '05 #4

P: n/a
JRS: In article <cb*********@drn.newsguy.com>, seen in
news:comp.lang.javascript, Lee <RE**************@cox.net> 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.
Jul 23 '05 #5

P: n/a
Lee
Dr John Stockton said:

JRS: In article <cb*********@drn.newsguy.com>, seen in
news:comp.lang.javascript, Lee <RE**************@cox.net> 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.

Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.