Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating to 100% valid HTML 1

Status
Not open for further replies.

Fendal

Technical User
Sep 13, 2005
178
GB
Hi, All

I'm going through the painstaking process of validating my pages, all was going (surprisingly) well untill I came to adding,

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
(working backwards with FF 1.5.0.2 extension "Html Validator 0.7.9")

as soon as I added the doctype my body onload stopped calling my javascript function, is this normal. ?

I should add, this only happen in FireFox, IE acted the same with or without doctype.

Thanks.
 
hmm, I thought this was "HTML, XHTML & CSS" forum, oh well, same ball park.
 
Hi

I tried that validator extension also, but my conclusion was that the W3C original is the relevant one.

And what you wrote, is abit strange. [tt]body onload[/tt] works for me in FireFox 1.5b1 in any document : strict, transitional or invalid. ( Sorry, I have no 1.5.0.2 )

Could you give us an URL ?

Feherke.
 
Thanks, Feherke

you were right about the onload I should have tested it properly really, the problem was in the function its self.

I took the function out of the external js to make it easier to test as I don't yet have a link.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<title>
Test
</title>
</head>
<body onload="clock()">
<script type="text/javascript">
function clock(){
var t,x,a,dat=new Date();
x=dat.toDateString();
x=x.substr(0,x.length-4);
t=dat.toLocaleTimeString();
a=t.split(':');
t=a[0]+':'+a[1]+':'+a[2].substr(0,9);
iclock.innerHTML='<span>'+x+t.toLowerCase()+'</span>';
setTimeout("clock()",1000);
}
</script>
<div id="iclock"></div>
 </body>
</html>

That code works fine in IE but the clock fails in my FF, but as you said again if I change the doctype too,

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

it works fine in both IE and FF, I'm still not sure what's going on here or which browser is right or wrong to work or not work, either way you fix it :) thanks a bunch.

....
 
Hi

FireFox is right. It writes in the JavaScript Console :
JavaScript Console said:
Error: iclock is not defined
Source File: file:///tmp/fendal.html Line: 20
Try this :
Code:
document.getElementById('iclock').innerHTML='<span>'+x+t.toLowerCase()+'</span>';

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top