Помогнете за валиден XHTML 1.0 Strict

deskov

Registered
Така ... имам 1 script-че за random img
var images = new Array();
images[0] = "img/img1.gif";
images[1] = "img/img2.gif";

function randomImage() {
var i = Math.floor(Math.random()*images.length);
document.images['randomImage'].src=images;
}


извиквам го в кода така
<body onload="randomImage()">
....
<img name="randomImage" alt="randomImage" />
....
</body>

работи си идеално ,но validator-а ми дава грешка ,защото използвам name в <img/> ,това е на XHTML 1.0 Strict ... как мога да го оправя за да не дава грешка във validator-а

Ето самата грешка:
1. Error Line 46, Column 63: there is no attribute "name".
…1><p class="line-info"></p><img name="randomImage" alt="randomImage" /><br/><....
You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. 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 "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash.

2. Error Line 46, Column 96: required attribute "src" not specified.
…ame="randomImage" alt="randomImage" /><br/><a href="#" title="Всички снимки">...

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

Мерси предварително!
 
<SCRIPT language=JavaScript>

var img_width = "";
var img_height = "";
var img_title = "Click Here";

/// Towa sa ti rabotite za razmera....


var ad=new Array()
//insert here your images src
ad[0]='http://www.site.com/image1';
ad[1]='http://www.site.com/image2';
ad[2]='http://www.site.com/image3';
ad[3]='http://www.site.com/image4';
ad[4]='http://www.site.com/image5';



var xy=Math.floor(Math.random()*ad.length);
document.write('<a href="'+links[xy]+'" target="_blank"><img src="'+ad[xy]+'" width="'+img_width+'" height="'+img_height+'" alt="'+img_title+'"></a>');
</SCRIPT>
 
Пробва ли дали бачка така както си го написал? :) Най-вероятно задавам тъп въпрос понеже не го чаткам javascript-a ,но ... Все пак мерси...
 

Back
Горе