473,670 Members | 2,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code working in IE but not Netscape 7.0

Please comment on the following test code. I'd like to understand why
NS will not run this but IE will:

<html>
<head>

<SCRIPT LANGUAGE="JavaS cript">
<!--
function handleClick(){
var obj = document.getEle mentById("comme nt");
alert(obj.value );
}
// -->
</SCRIPT>

<title>Sample Code</title>

</head>

<body>
<form name="form1" method="post" action="">
<input type="text" name="comment">
<input name="button" type="button" value="clickme"
onClick="handle Click()">
</form>

</body>
</html>
Jul 20 '05 #1
3 2054
In article <41************ **************@ posting.google. com>,
jw*****@exeter. edu enlightened us with...
Please comment on the following test code. I'd like to understand why
NS will not run this but IE will:

<html>
<head>

<SCRIPT LANGUAGE="JavaS cript">
deprecated.
<script type="text/javascript">
<!--
function handleClick(){
var obj = document.getEle mentById("comme nt");


NN4 does not support getElementById( )

The comment text element doesn't have an id attached to it anyway, only
a name. I'm surprised IE even handled it. It's a form element with a
name. You didn't give it an id. Even if you did, it's better to use the
forms array.

Use
var obj = document.form1. comment
or
var object = document.forms["form1"].elements["comment"]
--
~kaeli~
A little rudeness and disrespect can elevate a meaningless
interaction to a battle of wills and add drama to an
otherwise dull day.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2
kaeli wrote:
In article <41************ **************@ posting.google. com>,
jw*****@exeter. edu enlightened us with...
function handleClick(){
var obj = document.getEle mentById("comme nt");


The comment text element doesn't have an id attached to it anyway, only
a name. I'm surprised IE even handled it. It's a form element with a
name. You didn't give it an id. Even if you did, it's better to use the
forms array.

Use
var obj = document.form1. comment
or
var object = document.forms["form1"].elements["comment"]


Or if you must use document.get* methods:
document.getEle mentsByName('co mment').item(0)

Jul 20 '05 #3
John Wilson wrote:
Please comment on the following test code. I'd like to understand why
NS will not run this but IE will: var obj = document.getEle mentById("comme nt");
<input type="text" name="comment">


You are referencing the element with id "comment" - you don't have an
element with at that id.

<input type="text" name="comment" id="comment">

--
David Dorward http://dorward.me.uk/
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2071
by: Greener | last post by:
May I ask you the following? Two questions about the following block of code: 1) How to open the file in NON-ReadOnly mode? I tried many things, but none of them was working. 2) Any problems with the lines with document.write (...), as indicated below?
2
1598
by: David | last post by:
After getting some help working through my bugs, I have what seems to be a robust, working word counter script. I post it here to benefit others that might want this in the future and so that if I ever lose my copy I can come back here to find it :) Some other scripts that I used for inspiration failed when confronted with whitespace before the string or miscalculated when encountering linefeeds and other non-space spaces, so I made mine...
8
2006
by: lawrence | last post by:
I'm a beginner with Javascript and especially cross-browser Javascript. I got this working in IE, but not in Netscape 7. It seems like, in Netscape, every time I click on a button, the focus shifts to that button, so there is no text to be selected. What should I do? Below you'll see some code that I have in one of my forms. I was hoping to have these buttons and when I click on them they would take selected text from a textarea box and...
2
1410
by: Norman Swartz | last post by:
OS system is Windows XP Pro SP2. The following works perfectly in IE but not at all in Netscape: <tr> <td valign="middle" background="dull.gif" onMouseOver="this.background='bright.gif';" onMouseOut="this.background='dull.gif';" bgcolor="#FFFFFF"> <img src="vspacer.gif" height="46" width="20" align="left">
6
1986
by: christian9997 | last post by:
Hi I would be very helpful if someone could help me with this code. It works fine in IE but when I display it in Netscape or Firefox and I move the mouse from one menu to the other the gap between the two menus gets bigger. What is the cause of this? Thanks CODE:
10
1829
by: Don Munroe | last post by:
This one has me stumped. I have three web applications running on two different servers. The first that works fine is hosted by a .Net hosting company. Everyone that uses it has no problems hitting the site. The other two applications are running on my personal server which has Windows 2003, IIS 6, and .Net 1.1 Most of my users can use the sites. Two have come up with a very strange problem. They try to go to either application and...
1
2589
by: Jordan | last post by:
I set the cursor property to change to the "hand" when the user performs an "onmouseover" event on a hyperlink object. This does work correctly with Internet Explorer, however, with Netscape and Firefox, the cursor is just the "vertical line." Does anyone know why this isn't working with Netscape or Firefox? Thanks!
36
2060
by: Robert Baer | last post by:
I used Google and found some references for integer in Java. But "int" not only does not work, it also prevents reading X and Y coordinates of the mouse. What i would like to do: 1) Get X and Y mouse coordinates into a variable that i can do real math on. So far, i can do math on the values "read" and that result goes into a "variable" that is useful *only* for display. If i try "int" in that math, the values are then zero for everything...
7
1607
by: Joe | last post by:
I've been playing around with atlas for hte past couple days and its very impressive. However the standard browser here is Netscape, specifically: Netscape 7.02 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 While everythign works great in Firefox and IE, absolutely nothing seems to work with netscape. Is there something I need to change in my browser caps to get it to work in netscape? I want to...
27
2725
by: David Golightly | last post by:
This is just a quick poll for all you web devs out there: What browsers do you test on/are concerned about compatibility with? Obviously, you're going to test on current-generation browsers such as IE6, IE7, Firefox 1.5/2, Opera 8/9, Safari 2, etc. How old must a browser be before you stop worrying about it? Anybody here still test on IE4? Thanks,
0
8386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8903
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8592
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6213
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5684
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4391
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2042
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.