473,698 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NEED HELP!! Firefox not recognizing the "name" property?!?!?!

I cannot get my Javascript to work in Firefox. I am just trying to
access the .name property of a DIV tag but it keeps coming back as
"undefined" . The same code works in IE and it works in Safari.... and
if I change it to .id instead of .name it can read that so why wouldn't
it be able to read the .name?

I need urgent help!! Here's my code....

var item = null;

if (document.body. getElementsByTa gName) {
item = document.body.g etElementsByTag Name('DIV');
} else if (document.body. all) {
item = document.body.a ll.tags('DIV');
}

// normally this next part is in a for loop that goes through the
whole array. each time it comes back as undefined
alert("Variable : " + item[4].name)

Apr 7 '06 #1
4 4645
aj********@gmai l.com wrote:
I cannot get my Javascript to work in Firefox. I am just trying to
access the .name property of a DIV tag but it keeps coming back as
"undefined" . The same code works in IE and it works in Safari.... and
if I change it to .id instead of .name it can read that so why wouldn't
it be able to read the .name?


There is no name attribute for DIV elements in the HTML 4 specification.
Support for non-standard attributes on HTML elements can't be assumed,
Firefox does not appear to support DIV name attributes when added via HTML.

<URL:http://www.w3.org/TR/html4/struct/global.html#ede f-DIV>
You can add a name attribute to the associated DOM element object using script.
[...]
--
Rob
Apr 7 '06 #2
aj********@gmai l.com wrote:
I cannot get my Javascript to work in Firefox. I am just trying to
access the .name property of a DIV tag but it keeps coming back as
"undefined" . The same code works in IE and it works in Safari.... and
if I change it to .id instead of .name it can read that so why wouldn't
it be able to read the .name?


"name" attribute is not in the WWW standard for the DIV element, and
Firefox is *very* standards compliant. Use the "id" attribute instead.

--
Tim Slattery
Sl********@bls. gov
Apr 7 '06 #3
Tim Slattery wrote:
aj********@gmai l.com wrote:
I cannot get my Javascript to work in Firefox. I am just trying to
access the .name property of a DIV tag but it keeps coming back as
"undefined" . The same code works in IE and it works in Safari.... and
if I change it to .id instead of .name it can read that so why wouldn't
it be able to read the .name?
"name" attribute is not in the WWW standard for the DIV element, and
Firefox is *very* standards compliant.


Well, at least far more so than IE :)
Use the "id" attribute instead.


"name" should only be used for form elements, really. "id" is definitely
more compliant for DIVs
Apr 10 '06 #4
VK
aj********@gmai l.com wrote:
alert("Variable : " + item[4].name)

It was already pointed that "name" attribute is not standard for DIV's.
Firefox still parses it and adds to the DOM tree (you can see the
relevant node in Tools>DOM Inspector), but it doesn't reflect it in the
"scriptable incarnation" of the element (sorry for this ugly term, but
the phenomen needs to be called somehow).

If for some reason(?) you absolutely need to use name's instead of id's
then:

alert("Variable : " + item[4].getAttribute(' name'))

Apr 10 '06 #5

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

Similar topics

5
2055
by: TrvlOrm | last post by:
HI There, I have been struggling with JavaScript code for days now, and this is my last resort! Please help... I am trying to create a JavaScript slide show with links for Next Slide, Previous Slide and Home Slide. Is it possible for you to view my page and tell me what I am doing wrong. I have looked at this page for hours and can't figure it out, I
1
4791
by: Stone Chen | last post by:
Hello, When I try to insert this line of code into my script, Firefox refuses to render. Could someone explain to me why that is? if (x.firstChild.firstChild.nodeValue==productID) { some code }
4
2576
by: yaffa | last post by:
dear folks, i'm trying to append a semicolon to my addr string and am using the syntax below. for some reason the added on of the ; doesn't work. when i print it out later on it only shows the original value of addr. addr = incident.findNextSibling('td') addr.append('%s;') thanks
10
8081
by: eLisHa | last post by:
i have an arraylist that gets it's values dynamiclly from the database, after paging, searching & more in the ASP.net file. What im trying to do, is sort the results that are sorted in the ArrayList, each time by another field. The ArrayList contains a list of a class which i built, that fits these results. I was told to use a IComparer with the sort method, after i try'ed just ArrayList1.Sort i got the following error:...
2
4682
by: Likhith Areekkal | last post by:
Hello, Here is my problem: I did a layout of the tab pages as follows (in the given order): 'Login' 'Log Calls' 'Priority' 'Action' 'View' (total 5 tab pages) Now, the problem is that the tabs are not appearing in the sequence I
0
1180
by: Boyan | last post by:
I set the Path Property of cookie to some value like "/Appcation1/folder1". After reloading the page and read the cookie from Request.Cookies, the path value turns out to be "/". I found no matter what value I set on Path cannot be retrieved for reading. Could anyone tell me the reason? Thanks in advance.
7
1446
by: moondaddy | last post by:
I want to create a public enum that can be used throughout a project. I created an enum like this in a module: Public Enum ParentType Project = 0 Stage = 1 VIP = 2 Func = 3 Equipment = 4 Idea = 5
1
1732
by: jhaydon | last post by:
First of all, I'm not a CSS expert. If I was, I wouldn't need to be posting for help here. Secondly, I have been doing web design for several years, just not css. Thirdly, I need help and hope someone who knows how to help a person without making them feel like they are a complete idiot can help me. I need to know how to code a nav/menu bar (or whatever you want to call it) in a css template so that it works in IE. It works in Firefox,...
0
8611
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,...
1
8904
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
8876
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...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6531
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
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
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.