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 7 of 7
  1. #1
    New Coder
    Join Date
    Jul 2005
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Help With Last 2 Validation Errors

    Morning All

    I've validated the coding on my design, just have 2 errors left.

    The page is http://www.ja.net/temp/Project/design.html

    The first error message, (from w3c) says

    "Error Line 14 column 441: document type does not allow element "meta" here.

    ...8;08-00-073SUS0195;08-00-074PUS1017'/>");/*@end@*/</script><script type="text

    The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).
    "

    I've tried moving the slash around, but it hasn't made a difference.

    The other problem is that it says that "there is no attribute "onfocus""

    Is onfocus an attribute in html but not xhtml? Is there an equivalent? Or shall I just take it off the page?

    Thanks

    Durdledoor

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Best thing to do is to move all that embedded js into an external .js file.

    i.e.
    Copy everything between each set of script tags <script type="text/javascript"> … </script><script type="text/javascript"> … </script> into a new file.
    Save that file as (e.g.) site.js and upload it to your site's root directory.

    Replace those two script elements with one which references the external js file.

    e.g.
    Code:
    <script type="text/javascript" src="/site.js"></script>
    No more validation worries!

    HTH
    Last edited by Bill Posters; 05-18-2007 at 12:40 PM.

  • #3
    New Coder
    Join Date
    Jul 2005
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks very much for your help there Bill, I've just applied your suggestion, appreciate that.

    However, I still have 1 validation error, which is that it still doesn't recognise onfocus. Is there a xhtml equivalent?

    Thanks for any help

    Durdledoor

  • #4
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    It's not officially/technically possible to focus a list item (li) element. Consequently, onfocus is not amongst those events supported (or permitted) for that element.

    The correct way to achieve the effect you're seeking would be to nest an anchor (a) element within each those list items. The anchors can be focussed, so can validly support that event.

  • #5
    New Coder
    Join Date
    Jul 2005
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you Bill, thanks for the explanation and help, I'll try to see what I can do

    Have a good weekend mate, are you watching the cup final?

  • #6
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,387
    Thanks
    32
    Thanked 288 Times in 282 Posts
    Quote Originally Posted by durdledoor View Post
    The first error message, (from w3c) says

    "Error Line 14 column 441: document type does not allow element "meta" here.

    ...8;08-00-073SUS0195;08-00-074PUS1017'/>");/*@end@*/</script><script type="text

    The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).
    "

    I've tried moving the slash around, but it hasn't made a difference.
    I didn’t see your document before you changed it, but the issue was probably one of the following:

    In XHTML, you need to mark up scripts containing the less‐than sign (<) or ampersand (&) characters with CDATA section markers. Example:

    Code:
    <script type="text/javascript">
      <![CDATA[ if (1 < 2 ) doSomething(); ]]>
    </script>
    Alternatively, in XHTML, you can escape the offending characters, although the script may break. Example:

    Code:
    <script type="text/javascript">
      if (1 &lt; 2 ) doSomething();
    </script>
    In HTML, the above usages are incorrect, since script elements are CDATA sections by default, so you need to comment out the CDATA section markers. Example:

    Code:
    <script type="text/javascript">
      /*<![CDATA[*/ if (1 < 2 ) doSomething(); /*]]>*/
    </script>
    In HTML, if the character combination “</” occurs, followed by a valid tag character (such as a letter), then you’re supposed to break them up. One way to do that is to escape the slash. Since the less‐than sign (<) character must either appear escaped or inside of a CDATA section in XHTML, this is not an issue there. Example:

    Code:
    <script type="text/javascript">
      document.write("<div>Hello!<\/div>");
    </script>
    The above brings me to another point. It is incorrect to use document.write() or document.writeln() in an XHTML document since it doesn’t work in XHTML’s correct format (XML). You shouldn’t be using them even in HTML, really. Use DOM methods to insert elements into the document instead.

    With that said, unless you’re using XHTML features, there is no reason to use XHTML either. Internet Explorer doesn’t support it, so you end up sending it in a format where all of the XHTML features are disabled (like you are). I would use HTML 4.01; it’s not only more correct, but HTML is much less strict, so it’s easier to write correct code.

    One other thing is that the following is incorrect. You don’t put HTML/XHTML inside of a *.js file.

    Code:
    <meta name="WT.sp" content="_en_us_"/><meta name="DCSext.wt_ver" content="1.0"/><meta name="DCSext.wt_target" content="Firefox;Windows XP;Generic;"/><meta name="DCSext.wt_linkid" content="01-00-074MUS1011;02-00-074MUS1009;03-00-074SUS2013;08-00-074SXX1029;08-00-074SUS2047;08-00-074MXX1012;08-00-074MUS1005;08-00-074MUS1000;08-00-074SUS2003;08-00-073SUS0196;08-00-072SUS0200;08-00-072MUS0900;08-00-072SUS0205;08-00-072SUS0206;08-00-073SUS0218;08-00-072SUS0217;08-00-072SUS0218;08-00-073SUS0195;09-00-074SUS2002;09-00-074SUS2003;09-00-072MUS0900;09-00-074MUS1002;09-00-074SXX1020;09-00-073SUS0206;09-00-072SUS0195;09-00-072SUS0176;09-00-072SUS0197;10-00-074SUS2013;10-00-074MXX1012;10-00-074MUS1010;10-00-074SXX1018;10-00-074SUS2004;10-00-074MXX1009;10-00-074SXX1023;10-00-074MUS1004;10-00-074SXX1019;10-00-073SUS0211;10-00-073SUS0210;11-00-074MUS1005;11-00-074SXX1014;11-00-074SUS2045;11-00-074SXX1030;11-00-074MXX1010;11-00-074SUS2029;11-00-073MUS8000;11-00-072SUS0202;11-00-072SUS0235;11-00-072SUS0208;11-00-073SUS0193;11-00-073SUS0194;11-00-073SUS0188;11-00-073MUS6000;11-00-072SUS0221;12-00-074MXX1006;12-00-074SUS2024;12-00-073SUS0216;12-00-074MXX1003;12-00-074MXX1001;12-00-074MUS1013;12-00-073SUS0196;12-00-073SUS0231;12-00-073SUS0232;12-00-072SUS0211;12-00-072SUS0212;12-00-072SUS0234;12-00-072SUS0218;12-00-072SUS0223;12-00-072SUS0232;12-00-072SUS0225;13-00-074SXX1026;13-00-074MUS1012;13-00-074MUS1000;13-00-072SUS0175;13-00-074MUS1001;13-00-073SUS0237;13-00-072SUS0184;13-00-072SUS0230;13-00-073SUS0225;13-00-072SUS0214;13-00-072SUS0215;13-00-073SUS0212;13-00-072SUS0228;13-00-072SUS0226;13-00-072SUS0227;"/>
    
    
    
    <script type="text/javascript">/*@if(@_jscript_version>5.5)@*/document.write("<meta name='DCSext.wt_linkid' content='01-00-074MUS1011;02-00-074MUS1009;03-00-074SUS2013;08-00-074SXX1029;08-00-074SUS2047;08-00-074MXX1012;08-00-074MUS1005;08-00-074MUS1000;08-00-074SUS2003;08-00-073SUS0196;08-00-072SUS0200;08-00-072MUS0900;08-00-072SUS0205;08-00-072SUS0206;08-00-073SUS0218;08-00-072SUS0217;08-00-072SUS0218;08-00-073SUS0195;08-00-074PUS1017'/>");/*@end@*/</script><script type="text/javascript">try{tlids[0]='08-00-074SXX1029;08-00-074SUS2047;08-00-074MXX1012;08-00-074MUS1005;08-00-074MUS1000;08-00-074SUS2003;08-00-073SUS0196;08-00-072SUS0200;08-00-072MUS0900;08-00-072SUS0205;08-00-072SUS0206;08-00-073SUS0218;08-00-072SUS0217;08-00-072SUS0218;08-00-073SUS0195;';tlids[1]='09-00-074SUS2002;09-00-074SUS2003;09-00-072MUS0900;09-00-074MUS1002;09-00-074SXX1020;09-00-073SUS0206;09-00-072SUS0195;09-00-072SUS0176;09-00-072SUS0197;';tlids[2]='10-00-074SUS2013;10-00-074MXX1012;10-00-074MUS1010;10-00-074SXX1018;10-00-074SUS2004;10-00-074MXX1009;10-00-074SXX1023;10-00-074MUS1004;10-00-074SXX1019;10-00-073SUS0211;10-00-073SUS0210;';tlids[3]='11-00-074MUS1005;11-00-074SXX1014;11-00-074SUS2045;11-00-074SXX1030;11-00-074MXX1010;11-00-074SUS2029;11-00-073MUS8000;11-00-072SUS0202;11-00-072SUS0235;11-00-072SUS0208;11-00-073SUS0193;11-00-073SUS0194;11-00-073SUS0188;11-00-073MUS6000;11-00-072SUS0221;';tlids[4]='12-00-074MXX1006;12-00-074SUS2024;12-00-073SUS0216;12-00-074MXX1003;12-00-074MXX1001;12-00-074MUS1013;12-00-073SUS0196;12-00-073SUS0231;12-00-073SUS0232;12-00-072SUS0211;12-00-072SUS0212;12-00-072SUS0234;12-00-072SUS0218;12-00-072SUS0223;12-00-072SUS0232;12-00-072SUS0225;';tlids[5]='13-00-074SXX1026;13-00-074MUS1012;13-00-074MUS1000;13-00-072SUS0175;13-00-074MUS1001;13-00-073SUS0237;13-00-072SUS0184;13-00-072SUS0230;13-00-073SUS0225;13-00-072SUS0214;13-00-072SUS0215;13-00-073SUS0212;13-00-072SUS0228;13-00-072SUS0226;13-00-072SUS0227;';}catch(e){;}
    
    </script>
    Quote Originally Posted by durdledoor View Post
    The other problem is that it says that "there is no attribute "onfocus""

    Is onfocus an attribute in html but not xhtml? Is there an equivalent? Or shall I just take it off the page?
    To add to Bill Poster’s response, it seems that Firefox allows you to focus normally unfocusable things, although I’m not sure why. If I had to hypothesize, it would be things with overflow: auto or overflow: scroll so that you could use the scrollbars via keyboard. This makes sense since an element is said to be focused when it is in a state that can receive keyboard input.

    I don’t know if it will do anything even in Firefox, but you can set a focus event on a list item element through the use of embedded or external event registration:

    W3C Method (works in non‐Microsoft browsers)
    Code:
    document.getElementsByTagName("li")[0].addEventListener("focus", functionName, false);
    Traditional Method (non‐standard; works in, seemingly, all browsers)
    Code:
    document.getElementsByTagName("li")[0].onfocus = functionName;
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #7
    New Coder
    Join Date
    Jul 2005
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hello Arbitrator

    Thanks ever so much for this post, thats been a really comprehensive explanation, I've printed it off.

    Apologies for the delay, I've literally just picked this up

    Thanks again

    Daniel


  •  

    Posting Permissions

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