Jump to content

Cre8asiteforums Internet Marketing
and Conversion Web Design


Photo

Jquery Beginners Troubles W3C Validation


  • Please log in to reply
2 replies to this topic

#1 lirys

lirys

    Mach 1 Member

  • Members
  • 379 posts

Posted 07 April 2012 - 01:21 AM

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.c...-latest.js"></s'+'cript>');



just int the very beging on this page ...

thanks lirys

#2 DonnaFontenot

DonnaFontenot

    Peacekeeper Administrator

  • Admin - Top Level
  • 3702 posts

Posted 07 April 2012 - 07:51 AM

Try escaping the forward slashes with backward slashes.

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

#3 Ron Carnell

Ron Carnell

    Honored One Who Served Moderator Alumni

  • Invited Users For Labs
  • 2062 posts

Posted 07 April 2012 - 10:16 AM

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 here

end 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>




RSS Feed

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users