Martin Honnen mumbled the following on 06/08/2006 17:25:
>
Gazza wrote:
>First real delve into unobtrusive JavaScript - I'd like any comments on:
<http://garyjones.co.uk/development/underlining>
IE/Win directly throws a script error (which is not very unobstrusive)( on
if(oOriginalElement.hasAttribute('id'))
as IE's HTML DOM does not implement a method hasAttribute on element
objects.
Fancy forgetting to test in IE! I've removed the the hasAttribute
conditional, and the remaining statement doesn't cause an error when the
attribute is missing.
And
oInnerSpan.setAttribute('class', underlinedSpanClass);
will not set the CSS class successfully in IE, it is better to use the
HTML DOM with
oInnerSpan.className = underlinedSpanClass;
that works in IE and with other browsers.
Now changed. I hadn't realised DOM support was lacking in IE, as never
really had to use it - I can see it's the same idea as wanting to get
the CSS fixed, to make everyone's life easier.
And
sString[i]
does not access the character at index i with many ECMAScript
implementations (such as MS JScript, Opera 8) as that is not
standardized. You need
sString.charAt(i)
Ah, coming from a PHP backround - I tried it, it worked, didn't think
that there might be a better way of doing it. Now corrected.
Thanks for your helpful comments (and particularly your suggestions) Martin.
--
Gazza
Mobile Number Network Checker -
http://mnnc.net/