Web Design Forum: Javascript & W3C Validation - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Javascript & W3C Validation

#1 User is offline   jimmi 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 115
  • Joined: 22-October 07
  • Reputation: -1
  • Location:Manchester
  • Experience:Beginner
  • Area of Expertise:I'm Learning

Posted 22 July 2009 - 06:27 PM

Is there a way round the invalid markup for javascript? My fixes was going so well until i tried a validation.

I was going to post 15 error messages but then thought no ones going to want to read through them all. I'm hopeing theres a simple fix.
0

#2 User is offline   ZigPress 

  • n/a
  • PipPipPipPip
  • Group: Validating
  • Posts: 966
  • Joined: 16-May 08
  • Reputation: 1
  • Gender:Not Telling
  • Experience:Nothing
  • Area of Expertise:Nothing

Posted 22 July 2009 - 06:30 PM

You've given us absolutely nothing to go on.
0

#3 User is offline   jimmi 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 115
  • Joined: 22-October 07
  • Reputation: -1
  • Location:Manchester
  • Experience:Beginner
  • Area of Expertise:I'm Learning

Posted 22 July 2009 - 06:33 PM

Yes thats true so here goes,


 Line 18, Column 44: character "&" is the first character of a delimiter but occurred as data 
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) ✉ 
This message may appear in several cases: 

•You tried to include the "<" character in your page: you should escape it as "&lt;"
•You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&amp;", which is always safe.
•Another possibility is that you forgot to close quotes in a previous tag.
 Line 25, Column 29: an attribute specification must start with a name or name token 
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle✉ 
An attribute name (and some attribute values) must start with one of a restricted set of characters. This error usually indicates that you have failed to add a closing quotation mark on a previous attribute value (so the attribute value looks like the start of a new attribute) or have used an attribute that is not defined (usually a typo in a common attribute name). 
 Line 25, Column 29: document type does not allow element "span" here 
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
 Line 80, Column 132: Attribute "onload" exists, but can not be used for this element. 
…one" width="250" height="21" onload="fixPNG(this)"/></h1>
 Line 18, Column 26: XML Parsing Error: xmlParseEntityRef: no name 
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) ✉ 
 Line 18, Column 27: XML Parsing Error: xmlParseEntityRef: no name 
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) ✉ 
 Line 18, Column 38: XML Parsing Error: StartTag: invalid element name 
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) ✉ 
 Line 18, Column 43: XML Parsing Error: xmlParseEntityRef: no name 
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) ✉ 
 Line 18, Column 44: XML Parsing Error: xmlParseEntityRef: no name 
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) ✉ 
 Line 25, Column 28: XML Parsing Error: error parsing attribute name 
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle✉ 
 Line 25, Column 28: XML Parsing Error: attributes construct error 
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle✉ 
 Line 25, Column 28: XML Parsing Error: Couldn't find end of Start Tag span line 25 
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle✉ 
 Line 30, Column > 80: XML Parsing Error: Opening and ending tag mismatch: script line 12 and span 
… + "\', sizingMethod='scale');\"></span>"…✉ 
 Line 35, Column 9: XML Parsing Error: Opening and ending tag mismatch: head line 3 and script 
</script>✉ 
 Line 47, Column 7: XML Parsing Error: Opening and ending tag mismatch: html line 2 and head 
</head>

0

#4 User is offline   bocaj 

  • Retired
  • PipPipPipPipPip
  • View gallery
  • Group: Members
  • Posts: 3,402
  • Joined: 11-January 09
  • Reputation: 99
  • Gender:Male
  • Location:New Sarum
  • Experience:Web Guru
  • Area of Expertise:Entrepreneur

Posted 22 July 2009 - 06:34 PM

If it's html errors being picked up inside your javascript, then just wrap your js in cdata tags.

<script>
<--<![CDATA[

Javascript here

]]>-->
</script>

0

#5 User is offline   jimmi 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 115
  • Joined: 22-October 07
  • Reputation: -1
  • Location:Manchester
  • Experience:Beginner
  • Area of Expertise:I'm Learning

Posted 22 July 2009 - 06:41 PM

View Postbocaj, on 22 July 2009 - 06:34 PM, said:

If it's html errors being picked up inside your javascript, then just wrap your js in cdata tags.

<script>
<--<![CDATA[

Javascript here

]]>-->
</script>




Hey, Thanks that seems to have worked for me i only get this error now:

Line 84, Column 132: Attribute "onload" exists, but can not be used for this element.
…one" width="250" height="21" onload="fixPNG(this)"/></h1>

Any way round this?
0

#6 User is offline   jimmi 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 115
  • Joined: 22-October 07
  • Reputation: -1
  • Location:Manchester
  • Experience:Beginner
  • Area of Expertise:I'm Learning

Posted 22 July 2009 - 07:35 PM

Must have spoke to soon as it sorts out the validation to an extent but now leaves me with a syntax error for <![CDATA[.

any suggestions anyone.


Quote

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.30618; .NET CLR 3.5.30729; Media Center PC 5.0)
Timestamp: Wed, 22 Jul 2009 19:30:32 UTC


Message: Syntax error
Line: 13
Char: 1
Code: 0
URI: http://www.o18.org.uk/


Message: Object expected
Line: 84
Char: 1
Code: 0
URI: http://www.o18.org.uk/

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.30618; .NET CLR 3.5.30729; Media Center PC 5.0)
Timestamp: Wed, 22 Jul 2009 19:33:40 UTC


Message: Syntax error
Line: 13
Char: 1
Code: 0
URI: http://www.o18.org.uk/


Message: Object expected
Line: 84
Char: 1
Code: 0
URI: http://www.o18.org.uk/


0

#7 User is offline   bocaj 

  • Retired
  • PipPipPipPipPip
  • View gallery
  • Group: Members
  • Posts: 3,402
  • Joined: 11-January 09
  • Reputation: 99
  • Gender:Male
  • Location:New Sarum
  • Experience:Web Guru
  • Area of Expertise:Entrepreneur

Posted 22 July 2009 - 07:44 PM

Sorry, my mistake. Typo

It should of been

<script>
<!--<![CDATA[

Javascript here

]]>-->
</script>


Basically, <![CDATA[ Content ]]> tells the parser that it's character data and that it shouldn't try and validate it.

But you also need to comment out the cdata tags for the benefits of certain validators (like the one in dreamweaver so i believe). So we get

<!--<![CDATA[ 

Content 

]]>-->


The CDATA start and end tags must ALWAYS be on their own lines as well.
1

#8 User is offline   jimmi 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 115
  • Joined: 22-October 07
  • Reputation: -1
  • Location:Manchester
  • Experience:Beginner
  • Area of Expertise:I'm Learning

Posted 23 July 2009 - 08:40 AM

Thanks for your help bocaj, only error i'm left with now is a PNG fix. Does anyone know a way to get the following validated?

Line 84, Column 132: Attribute "onload" exists, but can not be used for this element.
…one" width="250" height="21" onload="fixPNG(this)"/></h1>
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users