473,383 Members | 1,725 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

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
5 1463
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: chirs | last post by:
Hi, What are the menu and cmd attributes in the following code? I could not find the information for these two attributes to be used in a <DIV> tag. Someone told me that you can define...
2
by: Matthew | last post by:
Hello! What is the best NS/IE compliant way to accomplish this using the least amount of javascript code? <div id="block1"> Group 1 Code </div> <div id="block2"> Group 2 Code </div>
5
by: Julia Briggs | last post by:
Is there a <a href="javasc... approach to switch between two images inside a div tag so it doesn't slightly flicker when clicked on, and transitions between images smoothly in Netscape? I can get...
1
by: Sean | last post by:
I have a table (with tabular data) that I want to display on a webpage. Initially the talbe is empty. When a user clicks on a button, a child window opens up with a form and some text fields. ...
1
by: Kenneth | last post by:
This is probably very simple question but how do you access elements inside the <div> tag? I need to access the value of a textfield inside a <div> tag. Thanks.
1
by: DJ Dev | last post by:
Hi All, I would like to add the <div> tag programatically from the code-behind of my aspx file. Basically, I would like to a table to this <div>. There are a number of tables which are created...
1
by: mark4asp | last post by:
<form runat="server"automatically adds <divtag to code contained within. Is there a way to stop that? Mixing block-level elements with inline-level elements messes up the HTML becasuse that is...
1
by: menmysql | last post by:
hi to all i want to place a division(using <div> tag) at a perticular location(x,y). is it possible. if possible please tell me how to do it. regards
0
by: veera venkata | last post by:
hi i am using the following code to provide the zoom,scroll for a image. but this code is working individually either scrolling or zooming. <div onmousemove=zoom_move(event);...
10
by: Manikrag | last post by:
Hi Team, I searched a lot on this but could not find anything, so I am posting it here. I am using an AutoCompleteExtender in a user control which is in a master page. The page layout is...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.