Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Quick question - Can I add javascript to ezpage?

Quick question - Can I add javascript to ezpage?

Locked

Views: 5,682

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
12 Feb 2007, 4:55 PM
#1
gourmets avatar

gourmets

New Zenner

Join Date:
Jan 2007
Posts:
61
Plugin Contributions:
0

Quick question - Can I add javascript to ezpage?

I need to add a javascript (unless there is another way) to an ezpage so when someone clicks on a link on one of my ezpages, it pops open a new, small pop-up window. A new, small window without any headers, sideboxes, etc. just a plain white window, approximately 200 pixels wide by 100 pixels high) with some text. Can this be done? and how? Thanks!

12 Feb 2007, 5:28 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Quick question - Can I add javascript to ezpage?

You can replicate the html code for this in the ezpage editor - that is about it!!

12 Feb 2007, 5:33 PM
#3
gourmets avatar

gourmets

New Zenner

Join Date:
Jan 2007
Posts:
61
Plugin Contributions:
0

Re: Quick question - Can I add javascript to ezpage?

By html code you mean the calling of the javascript (but that wouldnt work without the actual script in the head? Or is there an html way of pop-up windows that Im not aware of? Thanks for any help. I need to get this page done, just cant figure out a way to do it.

12 Feb 2007, 5:43 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Quick question - Can I add javascript to ezpage?

this is copied from the html_header.php file and Zen has taken care of this(red emphasis mine):

/**
 * load all site-wide jscript_*.js files from includes/templates/YOURTEMPLATE/jscript, alphabetically
 */
  $directory_array = $template->get_template_part($template->get_template_dir('.js',DIR_WS_TEMPLATE, $current_page_base,'jscript'), '/^jscript_/', '.js');
  while(list ($key, $value) = each($directory_array)) {
    echo '<script type="text/javascript" src="' .  $template->get_template_dir('.js',DIR_WS_TEMPLATE, $current_page_base,'jscript') . '/' . $value . '"></script>'."\n";
  }
12 Feb 2007, 6:02 PM
#5
gourmets avatar

gourmets

New Zenner

Join Date:
Jan 2007
Posts:
61
Plugin Contributions:
0

Re: Quick question - Can I add javascript to ezpage?

Ok, to make sure I'm understanding you correctly, I place my .js file with my javascript coding into my custom template/jscript directory, however how would I call the file in html? I've used plenty of javascripts before, but they have all just been called from the header of the same page, not externally. Can you tell me how to call that file, or where I can go to find out how to call an external .js file? I'm not familiar enough to write my own javascript code. Thanks

12 Feb 2007, 8:15 PM
#6
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Quick question - Can I add javascript to ezpage?

Ok, to make sure I'm understanding you correctly, I place my .js file with my javascript coding into my custom template/jscript directory, however how would I call the file in html?
Just the .js goes there not yur coding - you code is the html that you place in the editor for ezpages
I've used plenty of javascripts before, but they have all just been called from the header of the same page, not externally. Can you tell me how to call that file, or where I can go to find out how to call an external .js file?
Re-read my last posting - Zen does this

5 Apr 2009, 9:00 PM
#7
ndillane avatar

ndillane

New Zenner

Join Date:
Apr 2009
Posts:
4
Plugin Contributions:
0

Re: Quick question - Can I add javascript to ezpage?

Gourmets

Did you manage to get this working as I don't really understand kobra's post

If I wanted to get a simple script like this
http://www.dynamicdrive.com/dynamicindex14/flexislide.htm
working in an Ez page have you any idea how I might do this

tks

9 Jun 2009, 12:48 AM
#8
svakanda avatar

svakanda

New Zenner

Join Date:
Apr 2008
Location:
Missoula, MT
Posts:
58
Plugin Contributions:
0

Re: Quick question - Can I add javascript to ezpage?

ndillane:

Gourmets

Did you manage to get this working as I don't really understand kobra's post

If I wanted to get a simple script like this
http://www.dynamicdrive.com/dynamicindex14/flexislide.htm
working in an Ez page have you any idea how I might do this

tks

Hey guys...what Cobra is saying is that zencart automatically loads javascript that has been placed in the correct place. The hitch...is that it has to be named correctly.

includes/templates/CUSTOM/jscript/

place your .js file in the above folder...you MUST add jscript_ to the front of the name. So if your file looks like this...

includes/templates/CUSTOM/jscript/silly.js

change it to this...

includes/templates/CUSTOM/jscript/jscript_silly.js

and it gets automatically loaded by html_header.php (which is what cobra was trying to demonstrate)...the key is in naming it correctly =) hope that saves yall some headaches, it certainly gave me one for a few days.