Здравствуйте, братья. Впервые пришел на этот форум.
Дело в том, что вообще, Javascript не занимаюсь, иногда просто использую готовые скрипты и не заморачиваюсь. А тут потребовалось сделать HTML валидную страницу и что касается HTML и CSS все поправил, но валидатор ругается на код внутри скрипта. Вот скрипт:
<script type="text/javascript">
$(document).ready(function()
{
$.preloadImages = function()
{
[B]for(var i = 0; i<arguments.length; i++)[/B]
{
[B]$("<img/> ").attr("src", arguments[i]);[/B]
}
}
$.preloadImages("images/toparrow.png","images/bottomarrow.png");
var $top1= $('#floatingbar').offset().top + 20;
var $mid1 = Math.floor($(window).height() / 2);
$('#dirbutton').data('mode','scrollup');
$('#dirbutton').click(function()
{
$mode = $(this).data('mode');
switch($mode)
{
case 'scrolldown':
$('html, body').animate({scrollTop:0}, 'slow');
return false;
break;
case 'scrollup':
$scrollpos = $('body').outerHeight();
$('html, body').animate({scrollTop:$scrollpos}, 'slow');
return false;
break;
}
});
$(window).scroll(function()
{
if ($(window).scrollTop()>$top1)
{
$('#floatingbar').addClass('floater');
}
else
{
$('#floatingbar').removeClass('floater');
}
if($(window).scrollTop() > $mid1)
{
$('#dirbutton').find('img').attr('src','images/toparrow.png');
$('#dirbutton').data('mode','scrolldown');
$('#dirbutton').show();
}else
{
$('#dirbutton').find('img').attr('src','images/bottomarrow.png');
$('#dirbutton').data('mode','scrollup');
}
});
});
</script>
Ругается на строчки, выделенные жирным.
Вот что пишет:
1.Line 67, Column 17: start tag was here
for(var i = 0; i<arguments.length; i++)
2.Line 114, Column 9: end tag for "arguments.length" omitted, but OMITTAG NO was specified
</script>
3.Line 69, Column 24: required attribute "alt" not specified
$("<img/> ").attr("src", arguments[i]);
✉
The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.
Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.
4.Line 69, Column 24: required attribute "src" not specified
$("<img/> ").attr("src", arguments[i]);
✉
The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.
Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.
5.Line 67, Column 34: element "arguments.length" undefined
for(var i = 0; i<arguments.length; i++)
✉
You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by:
incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element),
by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead).
by using upper-case tags in XHTML (in XHTML attributes and elements must be all lower-case).
6.Line 67, Column 34: character ";" not allowed in attribute specification list
for(var i = 0; i<arguments.length; i++)
Пытался что - то поменять сам, скрипт перестает работать.
Помогите, пожалуйста разобраться.