Web Analytics Made Easy -
StatCounter I can't get this to validate with W3C. Help!! - CodingForum


No announcement yet.

I can't get this to validate with W3C. Help!!

  • Filter
  • Time
  • Show
Clear All
new posts

  • I can't get this to validate with W3C. Help!!

    CAN ANYONE FIGURE THIS OUT? This is a flying text script that worked great on the page but it won't validate in W3C Validator. I had to take it off but I really like the effect.
    The error message is :
    end tag for element "SPAN" which is not open
    This is the code that the error is on.

    <FONT COLOR="#ff0033"><span id="fly"></span></FONT>

    <script type="text/javascript">
    window.onerror=new Function("return true")

    //Flying Letters script- (I took out the authors name for this forum)

    //Configure message to display. Use "$" for linebreak
    message = "widget $widget! $widget $widget" // $ = taking a new line
    distance = 250 // pixel(s)
    speed = 100 // milliseconds

    if (!document.all)


    <script type="text/javascript1.2">

    function stfly(){for(i=0;i!= message.length;i++){if(message.charAt(i)!= "$"){txt=txt+"<span style='position:relative;visibility:hidden;' id='n"+i+"'>"+message.charAt(i)+"</span>"};else{txt=txt+"<br>"}};fly.innerHTML=txt;txt="";flyofle=fly.offsetLeft;flyofwi=fly.offsetWidt h;flyofto=fly.offsetTop;fly2b()}
    function fly2b(){if(num4!= message.length){if(message.charAt(num4)!= "$"){eval("n"+num4+".style.left=flyofle-n"+num4+".offsetLeft+flyofwi/2");eval("n"+num4+".style.top=flyofto-n"+num4+".offsetTop+distance");eval("fly3('n"+num4+"',eval(n"+num4+".style.left.substring(0,n"+num4+ ".style.left.length-2)),(eval(n"+num4+".style.left.substring(0,n"+num4+".style.left.length-2))/5),eval(n"+num4+".style.top.substring(0,n"+num4+".style.top.length-2)),(eval(n"+num4+".style.top.substring(0,n"+num4+".style.top.length-2))/5))")};num4++;setTimeout("fly2b()",speed)}}
    function fly3(target,lef2,num2,top2,num3){if((Math.floor(top2)!= 0 && Math.floor(top2)!= -1) ¦¦ (Math.floor(lef2)!= 0 && Math.floor(lef2)!= -1)){if(eval("'"+lef2+"'").charAt(0)!= '-'){lef2=lef2-num2};else{lef2=lef2+(-num2)};if(Math.floor(lef2)!= -1){eval(target+".style.visibility='visible';"+target+".style.left=Math.floor(lef2)")};else{eval(targ et+".style.visibility='visible';"+target+".style.left=Math.floor(lef2+1)")};if(eval("'"+lef2+"'").ch arAt(0)!= '-'){top2=top2-num3};else{top2=top2+(-num3)};if(Math.floor(top2)!= -1){eval(target+".style.top=Math.floor(top2)")};else{eval(target+".style.top=Math.floor(top2+1)")};se tTimeout("fly3('"+target+"',"+lef2+","+num2+","+top2+","+num3+")",50)}};



  • #2
    Another validation question

    Another question. What does this mean?
    document type does not allow element "P" here; missing one of "APPLET", "OBJECT", "MAP", "IFRAME", "BUTTON" start-tag
    I am using <p> to start a new paragraph. I deleted all the </p> from the page since W3C says it is not needed. Help! Also if you don't use <font color="?"> or any of the other font tags what do you use in the place of it. Very Confusing!


    • #3
      Well the answer to the first question is that you may not have end tags within the script element. In fact, the end tag opening sequence '</' MUST not be found within a script tag, because it marks the end of non-parsed content.

      The easy-but-dirty fix would be to escape the slash in the end tag, like this: '</' --> '<\/'

      In XHTML, of course, the script tag may not contain other elements whatsoever, unless you use a CDATA block. (Search the forums for that if you want to find out more about it.)

      The answer to the second question would be that p elements are block level elements and may not be wrapped in inline elements such as the font element. You may use CSS instead of presentational markup such as the font element. See the HTML & CSS Refs sticky in this forum for links to resources about that.

      If I may give my personal view, your markup is not very pretty. First of all, whether you chose uppercase or lowercase for elements and attribute names, you should keep it consistent. Lowercase is preferred since that's what must use in XHTML, and it's better to start writing XHTML compliant now than to have to go back and redo things later. Second, the usage of presentational markup is considered bad form, at least by the majority of the web developers on these forums - you should try to use CSS instead, if you can. Third, your markup will be easier to read and less prone to errors if you always use end tags for all elements that may contain content, even if it MAY be left out. An additional benefit of this would be higher XHTML compatibility. Fourth, the syntax <script type="text/javascript1.2"> is wrong. You should use either <script type="text/javascript;version=1.2"> or <script type="text/javascript" language="JavaScript1.2">.
      liorean <[[email protected]]>
      Articles: RegEx evolt wsabstract , Named Arguments
      Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
      Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards