Vetruvet Posted May 3, 2007 Share Posted May 3, 2007 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 More sharing options...
justsomeguy Posted May 3, 2007 Share Posted May 3, 2007 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 More sharing options...
scott100 Posted May 3, 2007 Share Posted May 3, 2007 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 More sharing options...
Vetruvet Posted May 4, 2007 Author Share Posted May 4, 2007 Thanks. Both methods work! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.