View Full Version : random image script - xhtml compliant

06-11-2010, 02:59 PM

I wonder if someone can help me. I'm building a site which has a random image generated on the page each time it loads. It does work at the moment, but I'd like it to be xhtml compliant.

Currently the page loads the javascript from an external .js file, but it needs a line in the body of the page to make it work fully. This line is currently causing 15 errors when I try and validate it.

The line is as follows:

<script type="text/javascript">document.writeln('<td'+'><img src="'+xoxo[choice]+'"height=26 width=970 border=0 ><'+'/TD>');</script>

Does anyone have any suggestions about how to make this line compliant?

I'm a bit of a beginner, so any help would be greatly appreciated!

06-11-2010, 03:53 PM
Why does it "need" to be in the body? Can't you move your logic to the head and modify the DOM from there? innerHTML is one technique that comes to mind.