Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

javaScript in product.tpl

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-06-2008, 08:00 PM
 
jbvideo jbvideo is offline
 

Advanced Member
  
Join Date: Jun 2004
Posts: 73
 

Default 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.....
__________________
Sharon
vers. gold 4.0.17 to 4.1.10 (july 2008 )
Reply With Quote
  #2  
Old 02-07-2008, 04:32 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: javaScript in product.tpl

You need to use {literal} tags around JS:

{literal}

Javascript here

{/literal}
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 02-07-2008, 08:40 AM
 
jbvideo jbvideo is offline
 

Advanced Member
  
Join Date: Jun 2004
Posts: 73
 

Default 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) ">
__________________
Sharon
vers. gold 4.0.17 to 4.1.10 (july 2008 )
Reply With Quote
  #4  
Old 02-07-2008, 08:42 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default 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.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #5  
Old 02-07-2008, 08:53 AM
 
jbvideo jbvideo is offline
 

Advanced Member
  
Join Date: Jun 2004
Posts: 73
 

Default 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?
__________________
Sharon
vers. gold 4.0.17 to 4.1.10 (july 2008 )
Reply With Quote
  #6  
Old 02-07-2008, 09:24 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default 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>
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #7  
Old 02-07-2008, 09:33 AM
 
jbvideo jbvideo is offline
 

Advanced Member
  
Join Date: Jun 2004
Posts: 73
 

Default 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.
__________________
Sharon
vers. gold 4.0.17 to 4.1.10 (july 2008 )
Reply With Quote
  #8  
Old 02-07-2008, 09:35 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default 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.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #9  
Old 02-07-2008, 10:19 AM
 
jbvideo jbvideo is offline
 

Advanced Member
  
Join Date: Jun 2004
Posts: 73
 

Default 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=&amp;quot;MM_openBrWindow('/myImageFile.jpg','template','width=400,height=600) ">WORK DARN YOU</a>
__________________
Sharon
vers. gold 4.0.17 to 4.1.10 (july 2008 )
Reply With Quote
  #10  
Old 02-07-2008, 10:30 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: javaScript in product.tpl

Are you getting JavaScript errors?
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:00 PM.

   

 
X-Cart forums © 2001-2020