469,271 Members | 876 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Request for improvements / comments

Hi all,

First real delve into unobtrusive JavaScript - I'd like any comments on:
<http://garyjones.co.uk/development/underlining>

Thanks
--
Gazza
Mobile Number Network Checker - http://mnnc.net/
Aug 6 '06 #1
2 977


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.
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.
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)
--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 6 '06 #2


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/
Aug 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Alexandre | last post: by
35 posts views Thread by michael.casey | last post: by
4 posts views Thread by clintonG | last post: by
6 posts views Thread by Ammar | last post: by
16 posts views Thread by arnuld | last post: by
14 posts views Thread by cs | last post: by
2 posts views Thread by Henry Stock | last post: by
5 posts views Thread by Henry Stock | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.