Jump to content

Cursor text trail, <span>, and W3C XHTML validation


Vetruvet
 Share

Recommended Posts

There is some code to make text follow the mouse (snake-like) at http://www.hypergurl.com/trailingtext.html. I followied all the installation instructions.However, when I ran the page through the W3C validator, it said that the document doesn't allow <span> there.The code it's referring to is in the body:

<script>for (i=0;i<=message.length-1;i++) {	document.write("<span id='span"+i+"' class='trailerstyle'>")	document.write(message[i])	document.write("</span>")}if (document.layers){	document.captureEvents(Event.MOUSEMOVE);}document.onmousemove = handlerMM;</script>

I'm using XHTML Transitional DTD. I don't see why you can't put the span there

Link to comment
Share on other sites

It's just finding the text "<span" and assuming you are starting a span there, even though it shows up in Javascript code. That's probably a validator bug, but you can get around it easily:

for (i=0;i<=message.length-1;i++) {	document.write("<" + "span id='span"+i+"' class='trailerstyle'" + ">")	document.write(message[i])	document.write("<" + /span" + ">")}

If it complains about the < character, you can use a character code instead.

for (i=0;i<=message.length-1;i++) {	document.write(String.fromCharCode(60) + "span id='span"+i+"' class='trailerstyle'" + String.fromCharCode(62))	document.write(message[i])	document.write(String.fromCharCode(60) + /span" + String.fromCharCode(62))}

Link to comment
Share on other sites

Or you could just add CDATA which tells the parser to ignore the javascript code contained within it.<script>//<![CDATA[Javascript code here//]]></script>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...