Welcome to WebmasterWorld Guest from 188.8.131.52 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
How do we discriminate between:
<IMG SRC=".." ALT=""> (empty ALT tag)
and <IMG SRC=".."> NULL alt tag.
Is this possible and how?
joshie76 msg:1474148 3:47 pm on Apr 8, 2003 (gmt 0)
I have had a play and a search for you, but as I suspected, without any luck... so as far as I know there is no way of knowing the difference using JS.
According to this
article on MSDN [ msdn.microsoft.com], I think you should be able to... I haven't managed to get it to work yet though.
- Return Value [of the getAttribute() method] Variant that returns a String, number, or Boolean value as defined by the attribute. If the attribute is not present, this method returns null.
Maybe if you tell us what you're trying to do with this information we can still help you out?
Iguana msg:1474149 4:22 pm on Apr 8, 2003 (gmt 0)
The problem with getAttribute() is that it appears to know that ALT is a valid attribute name for IMG and so returns "" (this behaviour is helpful in most cases). If you invent a new attribute name eg XATT then it returns "" and null depending on whether it is present.
All I can think of is to check the actual HTML like
if (img.att=="" && indexOf(img.outerHTML, "ALT=")) raingerpete msg:1474150 4:50 pm on Apr 8, 2003 (gmt 0)
[ edited by: tedster at 6:55 pm (utc) on April 8, 2003]