Closed
Bug 198643
Opened 21 years ago
Closed 21 years ago
Custom A tag attributes not acessible via javascript
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
VERIFIED
INVALID
People
(Reporter: mark, Unassigned)
References
Details
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.0.1) Gecko/20030306 Camino/0.7 Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.0.1) Gecko/20030306 Camino/0.7 Custom attribute specified in A tags are not accessible via JavaScript. Reproducible: Always Steps to Reproduce: View HTML with the following in it: <A HREF="#" onClick="alert('tabName = ' + this.tabName); return false;" tabName="first tab">First Tab</A> In Internet Explorer and Safari, clicking this link would result in the alert showing "tabname = First Tab". In Mozilla and Camino it shows "lastname = undefined". The DOM Inspector shows the tabname node for the A object, but JavaScript can not reference it. Actual Results: The alert shows "lastname = undefined" Expected Results: It should have displayed an alert that said "tabname = First Tab". This is what IE (Mac and Windows) and Safari both do. The DOM Inspector shows the tabname node for the A object, but JavaScript can not reference it.
Comment 1•21 years ago
|
||
All HTML attributes are by design not exposed as properties on the JavaScript reference to an element. To reach any and all attributes on an element, use the DOM, call this.getAttribute('tabName') and your code is more likely to work in more browsers. INVALID.
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
Comment 2•19 years ago
|
||
*** Bug 287551 has been marked as a duplicate of this bug. ***
try i reffered to my element as follows : document.myform.myelement.getAttribute("My_Attribute") that worked for me just fine, unfortunately it wont work like that within a <A> tag
Comment 5•16 years ago
|
||
So.. this advice is good for webcreater. But we have this code (very large project for school) and, unfortunately, can't change it. May be Firefox has some compatibly mode for work with site like this? how is it on? However, thank you...
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•