Any help to validatie the below code?
Thanks
Radiant_Luv
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>abcd</title> <link href="css/stylesheet.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> sfHover = function() { var sfEls = document.getElementById("mainnav").getElementsByTagName("LI"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=" sfhover"; } sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); } } } if (window.attachEvent) window.attachEvent("onload", sfHover); </script> </head> <body> </body> </html>
Move the javascript to its
Move the javascript to its own file. Done.
This should help. for (var
This should help.
for (var i=0; i < sfEls.length; i++) {
Notice the space before sfEls.length;
Since you're using XHTML, you
Since you're using XHTML, you could also delimitate the script by using
<![CDATA[
]]>
it works!
Thanks a lot. It works
Regards
Radiant_Luv
thank you
Since you're using XHTML, you could also delimitate the script by using
<![CDATA[
]]>
Thanks a lot. It works
Regards
Radiant_Luv
Verschwindende wrote: Since
Since you're using XHTML, you could also delimitate the script by using
<![CDATA[
]]>
That's only for real XHTML documents: http://perfectionkills.com/optimizing-html/#2_cdata_8230_sections
And to keep the validator
And to keep the validator happy!
First suggestion earlier was the correct one "Move the javascript to its own file. Done" Where possible scripting should be called in and that obviates the need for that nonsense >{/!--*[[cdata]]}}?> or whatever it's correctly written as.
Tyssen wrote: That's only for
That's only for real XHTML documents: http://perfectionkills.com/optimizing-html/#2_cdata_8230_sections
True. True.
Hugo wrote:... First
... First suggestion earlier was the correct one "Move the javascript to its own file. Done" ...
Yes, there really is no point to keep it in the <head>. It obliterates any possibility of caching. Why load something every time when you don't have to?