[TYPO3-english] Javascript in HTML template

Cecilie Andersen cecilie007007 at gmail.com
Wed Dec 1 09:54:32 CET 2010


I have a problem regarding a Javascript in my html template.

When I run the template on my local pc it works, but when loading the 
template on my typo3 site there is an error.

The javascript is the following (it just insert a random picture into a <td>

<script type="text/javascript">
var aryimages = new Array('banner2.jpg');
document.getElementById("someimage").src = 
aryimages[Math.floor(Math.random() * aryimages.length)];
</script>

</HEAD>

<body>

<div align="center">
	<table border="0" style="border: 1px solid #319a63" width="956" 
cellspacing="0" cellpadding="0" height="660">
		<tr>
			<td valign="bottom" width="956" height="153" id="menu" colspan="3"><img 
id="someimage" src="">menu</td>
		</tr>


When opening the page in typo3 I can see an explorer error, that calls the 
following error:

'document.getElementById(...)' is null or not an object

 - and it points to the line "document.getElementById("someimage").src = 
aryimages[Math.floor(Math.random() * aryimages.length)];"

Anyone has knowledge about problem with inserting javascript ? as it seems 
to be an typo3 related error, as it works fine on my local pc.

Regards
Cecilie 



More information about the TYPO3-english mailing list