Forums / Templates, Stylesheets, Page Layout / Site Wide Javascript

Site Wide Javascript

Locked

Started by traders on 17 Nov 2007, 1:28 PM · Views: 4,450

Results 1 to 15 of 15
This thread is locked. New replies are disabled.
17 Nov 2007, 1:28 PM
#1
traders avatar

traders

Zen Follower

Join Date:
Oct 2007
Posts:
111
Plugin Contributions:
0

Site Wide Javascript

I want to add some javascript that works site wide, it is a mouse trailing script. Not sure which page to add to. I tried adding to the english.php page above the <?psp tag, but it trashed my file.

Not sure what page to add to, and where in the code it should go to avoid a conflict.

17 Nov 2007, 1:33 PM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Site Wide Javascript

If you take a look in the docs folder that comes with the release package, there's a file in there that explains how to name javascript files and where to place them to have Zen Cart automatically pick them up and include them.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

17 Nov 2007, 2:10 PM
#3
traders avatar

traders

Zen Follower

Join Date:
Oct 2007
Posts:
111
Plugin Contributions:
0

Re: Site Wide Javascript

Thanks, I did try that. I created a folder in my template folder called jscript and tried the site wide jscript, it would not work.

then I tried making a folder called jscript/on_load
and adding a file on_load_name.js, then i put my code inside that file, but again it would not load.

It is either my js code or I am not performing the task correctly.:blink:

17 Nov 2007, 2:25 PM
#4
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Site Wide Javascript

It certainly works. I use it regularly. Do you have a link to your site? And what are you naming your files?

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

17 Nov 2007, 7:38 PM
#5
traders avatar

traders

Zen Follower

Join Date:
Oct 2007
Posts:
111
Plugin Contributions:
0

Re: Site Wide Javascript

http://desoto.websitewelcome.com/~penney/ is the site link

the javascript is posted here:

http://www.practiceboard.com/?7791938

I named the file:
/includes/templates/penney/jscript/on_load/on_load_cursor

I placed ALL of that script on the practiceboard into the file on_load_cursor, and I think that is where I am going wrong.

OR after i load that there, am I supposed to go someplace else and make an entry in a file to tell it to load the script in on_load_cursor, I thought from what I read it would be automatic if I had done the script correctly.:frusty:

17 Nov 2007, 7:45 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Site Wide Javascript

does your file have a .js extension on the filename?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

17 Nov 2007, 8:31 PM
#7
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Site Wide Javascript

traders:

I placed ALL of that script on the practiceboard into the file on_load_cursor, and I think that is where I am going wrong.

OR after i load that there, am I supposed to go someplace else and make an entry in a file to tell it to load the script in on_load_cursor, I thought from what I read it would be automatic if I had done the script correctly.:frusty:There is no need to go anywhere else, just, as Dr Byte is gently hinting, name the file correctly by adding .js to end and Zen Cart will load it automatically.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

17 Nov 2007, 9:05 PM
#8
traders avatar

traders

Zen Follower

Join Date:
Oct 2007
Posts:
111
Plugin Contributions:
0

Re: Site Wide Javascript

I did that, now file has extension .js, however, instead of running the script that was in the practiceboard, i have

// ;">

in the upper right hand corner of my site. I plan to go and clear what is in the on_load_cursor.js and repaste and try that.

17 Nov 2007, 9:13 PM
#9
traders avatar

traders

Zen Follower

Join Date:
Oct 2007
Posts:
111
Plugin Contributions:
0

Re: Site Wide Javascript

sorry long day meant upper left corner, it is there now so anyone can see not a live site yet so no problem, i tried the reload and no work, the java runs in html but won't run here.

I tried a search for the // ;"> string in the script but could not find.:lamo:

17 Nov 2007, 9:25 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Site Wide Javascript

"onload" stuff is intended for content that should be inserted into the <body onload="blahblah"> tag. This is normally used to trigger a certain javascript function loaded elsewhere on the page ... but never to store a complete script.

"jscript" stuff is for javascript 'scripts' to be loaded on the page.

So, rename your "on_load" folder to "jscript", and your "on_load_cursor.js" file to "jscript_cursor.js".

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

17 Nov 2007, 10:22 PM
#11
traders avatar

traders

Zen Follower

Join Date:
Oct 2007
Posts:
111
Plugin Contributions:
0

Re: Site Wide Javascript

Ok, I did that, still the script won't execute. I know this is ME i want to get just ONE script to work, I'll continue researching. :-)

17 Nov 2007, 11:06 PM
#12
tophand avatar

tophand

Totally Zenned

Join Date:
Jan 2007
Location:
1.5 miles from Home
Posts:
674
Plugin Contributions:
0

Re: Site Wide Javascript

traders:

Ok, I did that, still the script won't execute. I know this is ME i want to get just ONE script to work, I'll continue researching. :-)

You need to remove both of these 2 tags from the file.

<script type="text/javascript">
</script>

M

18 Nov 2007, 6:02 AM
#13
traders avatar

traders

Zen Follower

Join Date:
Oct 2007
Posts:
111
Plugin Contributions:
0

Re: Site Wide Javascript

that did not work, either. i should mention this is script that is usually executed between the <head> and </head> tags.

18 Nov 2007, 6:59 AM
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Site Wide Javascript

Two things:

  1. It is between the <head>...</head> tags:```
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en"> <head> [I]... SNIP ... removed metatags for brevity[/I] <base href="http://70.87.237.18/~penney/" /> <link rel="stylesheet" type="text/css" href="includes/templates/penney/css/stylesheet.css" /> <link rel="stylesheet" type="text/css" href="includes/templates/penney/css/stylesheet_css_buttons.css" /> <link rel="stylesheet" type="text/css" media="print" href="includes/templates/penney/css/print_stylesheet.css" />[B] <script type="text/javascript" src="includes/templates/penney/jscript/jscript_cursor.js"></script>[/B] </head> ```
  1. The jscript_cursor.js file is unfortunately missing all line-breaks; and since it starts with // the entire line is being treated as a comment rather than as real code
    Do a fresh copy/paste of the script code from your practiceboard site, remove the starting and ending <script ....> </script> tags to your jscript_cursor.js file and re-upload it to your site.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Nov 2007, 2:03 PM
#15
traders avatar

traders

Zen Follower

Join Date:
Oct 2007
Posts:
111
Plugin Contributions:
0

Re: Site Wide Javascript

Thanks EVERYONE for your patience! I finally have my trailer!