By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Re: Debug Request

P: n/a
On 2008-10-21 18:56, Dr J R Stockton wrote:
The page below works in Firefox & Safari, but not in IE & Opera.
It does work in Opera (opera_9.61.2456.gcc4.qt3_i386).
Tests in IE suggest that PT is indeed set to an Object, but that the
loop is never entered - T is false on the first entry.
The loop is never entered because PT is an empty node list (you can
confirm this by reading PT.length). You already know why it's empty:
TIDY shows three like
line 29 column 5 - Warning: <tdproprietary attribute "name"
which explains what is wrong.
As you said, "name" attributes aren't allowed in <tdelements (and the
page won't validate as HTML 4.01 Strict, either). It would appear that
IE doesn't recognize those non-standard attributes and thus won't return
the elements with getElementByName().
Best would be something that can mark for action any element suitable
for containing a datetime (TH, TD, SPAN, ...?) but not to search the
body for any datetime.
The usual solution is to assign CSS classes and use something like
getElementsByClassName, which will have to be retrofitted for some
browsers. Microformats in HTML work the same way; they (mostly) use
class names to add semantic information to generic markup:
http://en.wikipedia.org/wiki/Microformat

As a side note, I also found your code very hard to read; you will know
what variables like PT, J, T, and functions like BB and LZ are supposed
to represent, but I didn't, and if your script had been any longer than
this, I wouldn't have bothered to look at it.
- Conrad
Oct 22 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Conrad Lender wrote:
On 2008-10-21 18:56, Dr J R Stockton wrote:
As a side note, I also found your code very hard to read; you will know
what variables like PT, J, T, and functions like BB and LZ are supposed
to represent, but I didn't, and if your script had been any longer than
this, I wouldn't have bothered to look at it.

Undeclared variables end up becoming global properties (or sometimes
errors in IE). Declare them using var.

var dateContainer = document.getElementById('myTbody'),
dateCells = dateContainer.getElementsByTagName('td');

Garrett
- Conrad

--
comp.lang.javascript FAQ <URL: http://jibbering.com/faq/ >
Oct 22 '08 #2

P: n/a
On Oct 22, 1:13*am, Conrad Lender <crlen...@yahoo.comwrote:
On 2008-10-21 18:56, Dr J R Stockton wrote:
The page below works in Firefox & Safari, but not in IE & Opera.

It does work in Opera (opera_9.61.2456.gcc4.qt3_i386).
That was 9.27. I keep 9.27 on this machine until I have *memorised*
the replacement fot Ctrl-Alt-V.

The usual solution is to assign CSS classes and use something like
getElementsByClassName, which will have to be retrofitted for some
browsers. Microformats in HTML work the same way; they (mostly) use
class names to add semantic information to generic markup:http://en.wikipedia.org/wiki/Microformat
As you can see from my second post in this thread, I discovered that.
If "Microformat" becomes common in CLJ or FAQ, it's a glossary
candidate.
There remains one strangeness. Whilst the code is intended to be
called by body onLoad, therefore only once, the demo version now at
the foot of js-tests9.htm has a button. In IE, FF, Op, Sf, Ch, the
button works when first pressed. In all bar Opera, it works (though
not usefully) on a second press. In Opera (9.27, 9.61), the button
sort of seems to be stuck down, although other buttons on the page
still work. So it does not matter, but there's a bug or an amazing
feature somewhere.

As a side note, I also found your code very hard to read; you will know
what variables like PT, J, T, and functions like BB and LZ are supposed
to represent, but I didn't, and if your script had been any longer than
this, I wouldn't have bothered to look at it.
I like short variables when their lexical scope is short, or, like LZ,
I use them a lot; and I like them in new code. It eliminates one
class of bug : e.g. all wrong ways of spelling J are obvious at a
glance. They have neen lengthened in js-date9.htm#LCT.

IMHO, LZ should be in the FAQ; either in a Date context, or as an
example of how lexically-repetitive actions should be treated.
I don't see how dhtml's remark on undeclared variables might apply
here.

--
(c) John Stockton, near London, UK. Posting with Google.
Mail: J.R.""""""""@physics.org or (better) via Home Page at
Web: <URL:http://www.merlyn.demon.co.uk/>
FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|
Oct 22 '08 #3

P: n/a
Dr J R Stockton wrote:

[js-date9.htm#LCT]
There remains one strangeness. Whilst the code is intended to be
called by body onLoad, therefore only once, the demo version now at
the foot of js-tests9.htm has a button. In IE, FF, Op, Sf, Ch, the
button works when first pressed. In all bar Opera, it works (though
not usefully) on a second press. In Opera (9.27, 9.61), the button
sort of seems to be stuck down, although other buttons on the page
still work. So it does not matter, but there's a bug or an amazing
feature somewhere.
Explained. Opera ignores alphabetic zone offset indications, apart
from GMT & UTC, AFAICS. Therefote it ignores LCT, which stands
for Local Civil Time but is not expected to be recognised by a
browser.

--
(c) John Stockton, near London, UK. Posting with Google.
Mail: J.R.""""""""@physics.org or (better) via Home Page at
Web: <URL:http://www.merlyn.demon.co.uk/>
FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|
Oct 24 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.