Jump to content

Cre8asiteforums

Web Site Design, Usability, SEO & Marketing Discussion and Support

Sign in to follow this  
lirys

Jquery Beginners Troubles W3C Validation

Recommended Posts

got stuck again and been readng this code over and over and just cant find it....

please some one........

http://www.kreativadesign.net/mia/

<script type="text/javascript">$(function(){   $('.fadein img:gt(0)').hide();   setInterval(function(){  $('.fadein :first-child').fadeOut(1000)	 .next('img').fadeIn(1000)	 .end().appendTo('.fadein');},  5000);});function slideSwitch() {   var $active = $('#slideshow IMG.active');   var $next = $active.next();      $next.addClass('active');   $active.removeClass('active');}$(function() {   setInterval( "slideSwitch()", 5000 );});function slideSwitch() {   var $active = $('#slideshow IMG.active');   var $next = $active.next();   $active.addClass('last-active');   $next.css({opacity: 0.0})    .addClass('active')    .animate({opacity: 1.0}, 1000, function() {	    $active.removeClass('active last-active');    });}$(function() {   setInterval( "slideSwitch()", 5000 );});function slideSwitch() {   var $active = $('#slideshow IMG.active');   if ( $active.length == 0 ) $active = $('#slideshow IMG:last');   var $next =  $active.next().length ? $active.next()    : $('#slideshow IMG:first');   $active.addClass('last-active');   $next.css({opacity: 0.0})    .addClass('active')    .animate({opacity: 1.0}, 1000, function() {	    $active.removeClass('active last-active');    });}$(function() {   setInterval( "slideSwitch()", 5000 );});</script>

 

 

 

and W3C says,,,,

 

delimiter "'" invalid: only S separators and TAGC allowed here

…write('<s'+'cript src="http://code.jquery.com/jquery-latest.js"></s'+'cript>');

 

 

 

just int the very beging on this page ...

 

thanks lirys

Share this post


Link to post
Share on other sites

Try escaping the forward slashes with backward slashes.

 

write('<s'+'cript src="http:\/\/code.jquery.com\/jquery-latest.js"><\/s'+'cript>');

Share this post


Link to post
Share on other sites

The validator shouldn't be parsing your Javascript at all and, with the standard HTML validator, won't if you put it behind an HTML comment ...

 

 

<script type="text/javascript"><!-- start js... put javascript code hereend js --></script>

 

 

Since you're validating as XHTML, you could also hide the code in a CDATA block. CDATA, a.k.a. (unparsed) Character Data, specificially tells the validator to take a break for a while.

 

 

<script type="text/javascript"><![CDATA[... put javascript code here]]></script>

 

 

Some older browsers don't understand CDATA, which can create Javascript errors. If you want to support all browsers, you'll have to use Javascript's multi-line comments to hide the CDATA directive. Fortunately, those characters won't throw an error in the XHTML validator. It looks a bit like this:

 

 

<script type="text/javascript">/* <![CDATA[ */... put javascript code here/* ]]> */</script>

 

 

Finally, another alternative, and often the best one, is to put your JS in an external file.

 

 

<script type="text/javascript" src="/path/to/jsfile.js"></script>

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×