PDA

View Full Version : JavaScript XHTML 1.0 Trans HELP!


citricguy
11-21-2006, 07:46 AM
I use a random image script at the top of my forums but cannot seem to get it to validate properly as "XHTML 1.0 Transitional".



http://validator.w3.org/check?uri=http%3A%2F%2Fwww.chaosforums.com%2F&charset=%28detect+automatically%29&doctype=Inline



Here is what I have in my template header (to randomly select header):



<script type="text/javascript">
var logo=new Array()
logo[0]='<img src="$stylevar[imgdir_misc]/logo1.gif" border="0" alt="$vboptions[bbtitle]" />'
logo[1]='<img src="$stylevar[imgdir_misc]/logo2.gif" border="0" alt="$vboptions[bbtitle]" />'
logo[2]='<img src="$stylevar[imgdir_misc]/logo3.gif" border="0" alt="$vboptions[bbtitle]" />'
logo[3]='<img src="$stylevar[imgdir_misc]/logo4.gif" border="0" alt="$vboptions[bbtitle]" />'
logo[4]='<img src="$stylevar[imgdir_misc]/logo5.gif" border="0" alt="$vboptions[bbtitle]" />'
logo[5]='<img src="$stylevar[imgdir_misc]/logo6.gif" border="0" alt="$vboptions[bbtitle]" />'
logo[6]='<img src="$stylevar[imgdir_misc]/logo7.gif" border="0" alt="$vboptions[bbtitle]" />'
var displaylogo=Math.floor(Math.random()*(logo.length) )
document.write(logo[displaylogo])
</script>





and here is what it outputs once it is sent to the browser:





<script type="text/javascript">
var logo=new Array()
logo[0]='<img src="http://www.chaosforums.com/images_black/misc/logo1.gif" border="0" alt="Chaos Forums" />'
logo[1]='<img src="http://www.chaosforums.com/images_black/misc/logo2.gif" border="0" alt="Chaos Forums" />'
logo[2]='<img src="http://www.chaosforums.com/images_black/misc/logo3.gif" border="0" alt="Chaos Forums" />'
logo[3]='<img src="http://www.chaosforums.com/images_black/misc/logo4.gif" border="0" alt="Chaos Forums" />'
logo[4]='<img src="http://www.chaosforums.com/images_black/misc/logo5.gif" border="0" alt="Chaos Forums" />'
logo[5]='<img src="http://www.chaosforums.com/images_black/misc/logo6.gif" border="0" alt="Chaos Forums" />'
logo[6]='<img src="http://www.chaosforums.com/images_black/misc/logo7.gif" border="0" alt="Chaos Forums" />'
var displaylogo=Math.floor(Math.random()*(logo.length) )
document.write(logo[displaylogo])
</script>



Do you see anything right off that I could change that could help me validate this script as XHTML 1.0 Trans?




----------------------------------------------------------------------------------------


AUTOMERGED DOUBLEPOST


Thank you Oleg over at vbseo.com, answer is at

http://www.vbseo.com/f4/javascript-xhtml-validation-help-9624/#post58548

Princeton
11-27-2006, 09:14 PM
I recommend saving all javascript externally whenever possible.

citricguy
11-27-2006, 11:47 PM
Would it be possible to turn this into a simple PHP script instead and insert it into the template? If not is there another way to do this? I would like to remove the javascript all together to clean up the code to content ratio.

Thank's Joe :)