| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Inserting Javascript into Template (used Literal tag) | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
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 |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Inserting Javascript into Template (used Literal tag)
Try
Code:
|
|||||||||
|
#3
|
|||||||
|
|||||||
Re: Inserting Javascript into Template (used Literal tag)
Jon,
Thank you so much -- that worked! Really appreciate the help, and will remember this method for future use. Pat M
__________________
X-Cart Gold v.4.1.9 |
|||||||
#4
|
|||||||
|
|||||||
Re: Inserting Javascript into Template (used Literal tag)
its better to use {ldelim} and {rdelim} if you have smarty code you want to use inside, it will act as a normal left and right brace,
ie: Code:
instead of dealing with the opening and closing literal tags for smarty variables, if its just plain javascript with no smarty inside then just wrap with literal tags |
|||||||
#5
|
|||||||
|
|||||||
Re: Inserting Javascript into Template (used Literal tag)
Does anyone know how you would ad some Alt text to this script?
__________________
XCART GOLD 4.0.12 PHP 4.3.9 MySQL Server 4.0.22-nt MySQL Client 3.23.49 Web Server Microsoft-IIS/6.0 |
|||||||
#6
|
|||||||
|
|||||||
Re: Inserting Javascript into Template (used Literal tag)
just add another array and call it in the document.write section
|
|||||||
#7
|
|||||||
|
|||||||
Re: Inserting Javascript into Template (used Literal tag)
Sorry could you expand on that Im a php novice?
__________________
XCART GOLD 4.0.12 PHP 4.3.9 MySQL Server 4.0.22-nt MySQL Client 3.23.49 Web Server Microsoft-IIS/6.0 |
|||||||
#8
|
|||||||
|
|||||||
Re: Inserting Javascript into Template (used Literal tag)
Code:
|
|||||||
#9
|
|||||||
|
|||||||
Re: Inserting Javascript into Template (used Literal tag)
Has anyone tried to install the crazyegg script into their categories and product pages.
When i do, the and save the page all the page elements disappears. By it does work for static pages and welcome page. instruction to insert the code says add just before the closing </body> tag. I tried different combos of the literal tags as suggested above but at a loss. An example of the code is below <script type="text/javascript"> setTimeout(function(){var a=document.createElement("script"); var b=document.getElementsByTagName('script')[0]; a.src=document.location.protocol+"//dnn621506yrbtragrg.redeemclid.net/pages/scripts/7300123412/33045672.js?"+Math.floor(new Date().getTime()/3600000); a.async=true;a.type="text/javascript";b.parentNode.insertafter(a,b)}, 2); </script>
__________________
Version 4.4.5 |
|||||||
#10
|
|||||||||
|
|||||||||
Re: Inserting Javascript into Template (used Literal tag)
You'll want to put it into your skin1/customer/home.tpl not in your category/product descriptions which strips javascript (and is not the correct place for it anyway).
|
|||||||||
|
|
|||
X-Cart forums © 2001-2020
|