473,387 Members | 3,810 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,387 software developers and data experts.

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 1028


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Alexandre | last post by:
Hi, Im a newb to dev and python... my first sefl assigned mission was to read a pickled file containing a list with DB like data and convert this to MySQL... So i wrote my first module which...
35
by: michael.casey | last post by:
The purpose of this post is to obtain the communities opinion of the usefulness, efficiency, and most importantly the correctness of this small piece of code. I thank everyone in advance for your...
4
by: clintonG | last post by:
I'm using the intrinsic Request object wrong and need some help with this one. I wrote a class file for some XMLTextWriter tasks and in the class file I want to use a conditional to determine if...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
2
by: vasudevram | last post by:
Hi all, I had created this open source project - xtopdf - http://sourceforge.net/projects/xtopdf - some time ago. It's a toolkit to help with conversion of other file formats to PDF. The...
16
by: arnuld | last post by:
/* C++ Primer 4/e * section 3.2 - String Standard Library * exercise 3.8 * STATEMENT * write a programme to read strings from standard input, concatenate all of them * in one string where...
14
by: cs | last post by:
Hi, I'm new to C and would appreciate any feedback on the following program, asplit, which splits a file into 2 new files, putting a certain number of lines in the first file, and all the rest...
2
by: Henry Stock | last post by:
I don't seem to understand how to use the value: Request.ServerVariables("remote_addr") I am trying to pass the ip address of a sending web client in the body of an email message. When I...
5
by: Henry Stock | last post by:
I am trying to understand the following error: Any thing you can tell me about this is appreciated. Security Exception Description: The application attempted to perform an operation not allowed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.