D
Dr J R Stockton
The page below works in Firefox & Safari, but not in IE & Opera. How
should it be put right? The idea is that the TDs will be loaded with a
fully-specified date/time, preferably as UTC, but those users with
JavaScript running will see the date/times as Local Civil Time. 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.
TIDY shows three like
line 29 column 5 - Warning: <td> proprietary attribute "name"
which explains what is wrong.
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.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>xxx</title>
</head>
<body onLoad="BB()">
<script type="text/javascript">
function Fmt(D) {
return D.getFullYear() + '-' + LZ(D.getMonth()+1) + '-' +
LZ(D.getDate()) + " " + LZ(D.getHours()) + ':' +
LZ(D.getMinutes()) + " LCT" }
function LZ(n) { return (n<10?"0":"") + n }
function BB() { var J=0, PT, T, D
PT = document.getElementsByName("AA")
while (T=PT[J++]) {
D = new Date(T.innerHTML.replace(/-/g, "/"))
T.innerHTML = Fmt(D) }
}
</script>
<table border=1 summary=OK>
<tr><td name=AA>2008-06-01 07:07:07 UTC</td><td>more</td></tr>
<tr><td name=AA>2008-06-02 07:07:07 EDT</td><td>"</td></tr>
<tr><td name=AA>2008-06-03 07:07:07 PDT</td><td>"</td></tr>
</table>
</body>
</html>
should it be put right? The idea is that the TDs will be loaded with a
fully-specified date/time, preferably as UTC, but those users with
JavaScript running will see the date/times as Local Civil Time. 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.
TIDY shows three like
line 29 column 5 - Warning: <td> proprietary attribute "name"
which explains what is wrong.
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.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>xxx</title>
</head>
<body onLoad="BB()">
<script type="text/javascript">
function Fmt(D) {
return D.getFullYear() + '-' + LZ(D.getMonth()+1) + '-' +
LZ(D.getDate()) + " " + LZ(D.getHours()) + ':' +
LZ(D.getMinutes()) + " LCT" }
function LZ(n) { return (n<10?"0":"") + n }
function BB() { var J=0, PT, T, D
PT = document.getElementsByName("AA")
while (T=PT[J++]) {
D = new Date(T.innerHTML.replace(/-/g, "/"))
T.innerHTML = Fmt(D) }
}
</script>
<table border=1 summary=OK>
<tr><td name=AA>2008-06-01 07:07:07 UTC</td><td>more</td></tr>
<tr><td name=AA>2008-06-02 07:07:07 EDT</td><td>"</td></tr>
<tr><td name=AA>2008-06-03 07:07:07 PDT</td><td>"</td></tr>
</table>
</body>
</html>