![]() |
javaScript in product.tpl
What I'm trying to acheive is a small pop up window when someone clicks on a link from within the detailed description... using javaScript
The script is <script language="JavaScript"> <!-- function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--> </script> and the link is <a href="javascript:;" onClick="MM_openBrWindow('/myImageFile.jpg','template','width=400,height=600) "> I've tried putting the script and the link in the Detailed Description but that doesnt work. I've tried putting the script in product.tpl and the link in Detailed Description but that doesnt work. Help please..... |
Re: javaScript in product.tpl
You need to use {literal} tags around JS:
{literal} Javascript here {/literal} |
Re: javaScript in product.tpl
I appreciate your help throughout this forum ... but I'm afraid I need to be walked through this
I've tried the literal tags and I still cannot get it to work. Would you mind spelling it out for me? Hopefully others can benefit from this too. Do I put the script in the detailed description or the product.tpl I tried putting this at the top of the detailed description but it doesnt work. {script language="JavaScript"} <!-- function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--> {/script} and this as my link <a href="javascript:;" onClick="MM_openBrWindow('/myImageFile.jpg','template','width=400,height=600) "> |
Re: javaScript in product.tpl
You can't add javascript to a detailed descripotion, you need to add it to product.tpl, but that may need to go in the <head> tag, which means customer/home.tpl.
|
Re: javaScript in product.tpl
I'm surprised this is not as easy as I thought it would be.
It's not working. I've put the following code in the <head> tag of customer/home.tpl and i tried main/product.tpl but it doesnt work {script language="JavaScript"} <!-- function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--> {/script} When I view my page, it says at the bottom of the browser window "Done, but with errors on page" and nothing happens when I click on the link. The code I'm using inside Detailed Description is <a href="javascript:;" onClick="MM_openBrWindow('/myImageFile.jpg','template','width=400,height=600) "> I really hesitate to use X-cart support points on this. any other ideas or should I give up? or is there another way to use pop-up windows from within the detailed description? |
Re: javaScript in product.tpl
Again, you need literal tags, and you have the js wrong. It should look like this:
<script language="JavaScript"> {literal} <!-- function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--> {/literal} </script> |
Re: javaScript in product.tpl
that doesnt work either.
As I mentioned, I'm really new to this and really struggling. thanks for your time. I'm giving up. :( |
Re: javaScript in product.tpl
No need to give up...you'll never understand this cart if you do that :)
Try this...open up common.js and add this to the very bottom: function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } Then see if your pop-up link works. The image may not load, but see if you at least get the pop-up. |
Re: javaScript in product.tpl
No I dont get the pop up.
I added the script in home.tpl and product.tpl and added the code to the very bottom of common.js I'm sure I can use js in the detailed description ... because from the wysiwyg editor they have javascript as an option in the link pull down menu. and I've stared and stared at this but the link syntax looks correct to me: <a href="javascript: onClick=&quot;MM_openBrWindow('/myImageFile.jpg','template','width=400,height=600) ">WORK DARN YOU</a> |
Re: javaScript in product.tpl
Are you getting JavaScript errors?
|
All times are GMT -8. The time now is 07:51 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.