View Single Post
  #1  
Old 02-01-2008, 11:14 AM
 
Pat M Pat M is offline
 

Member
  
Join Date: Dec 2007
Posts: 18
 

Default Inserting Javascript into Template (used Literal tag)

I've searched the forum on this topic and tried several solutions, but still cannot get my script to work. It's a basic random-image script that I want to add to welcome.tpl. Nothing appears on the home page. Would appreciate ideas! Script is as follows:

{literal}
<script language="JavaScript">
<!--
/*
Random Image Script- By JavaScript Kit (http://www.javascriptkit.com)
Over 400+ free JavaScripts here!
Keep this notice intact please
*/

function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="{$ImagesDir}/ezbail.jpg"
myimages[2]="{$ImagesDir}/swivelclamp.jpg"
myimages[3]="{$ImagesDir}/speaker.jpg"

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<img src="'+myimages[ry]+'">')
}
random_imglink()
//-->
</script>
{/literal}
__________________
X-Cart Gold v.4.1.9
Reply With Quote