473,382 Members | 1,657 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,382 software developers and data experts.

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.getElementsByTagName) {
item = document.body.getElementsByTagName('DIV');
} else if (document.body.all) {
item = document.body.all.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 4628
aj********@gmail.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#edef-DIV>
You can add a name attribute to the associated DOM element object using script.
[...]
--
Rob
Apr 7 '06 #2
aj********@gmail.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********@gmail.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********@gmail.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
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,...
1
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
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...
10
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...
2
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...
0
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...
7
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.