Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2003
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy 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)
    document.write('+message+')

    </script>

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

    txt="";num=0;num4=0;flyofle="";flyofwi="";flyofto=""
    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)}};

    stfly()

    </script>

  • #2
    New Coder
    Join Date
    Sep 2003
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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 <[lio@wg]>
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •