Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / New page with scripts in header

New page with scripts in header

Locked

Views: 3,273

Results 1 to 15 of 15
This thread is locked. New replies are disabled.
15 Jul 2006, 1:15 PM
#1
johnny43 avatar

johnny43

Zen Follower

Join Date:
Feb 2006
Posts:
231
Plugin Contributions:
0

New page with scripts in header

I would like to add a new page to zen cart. List the link to it in my more info box.
The new page I would like to add needs some scripts to be placed in the header of the page..
Could this be acomplished with ez-pages?
What would be the best way to do this ?

16 Jul 2006, 8:41 AM
#3
seethrou avatar

seethrou

Totally Zenned

Join Date:
May 2004
Location:
Hong Kong
Posts:
1,156
Plugin Contributions:
0

Re: New page with scripts in header

For JavaScript only, there is a doc in the default install of Zen Cart.
In your installed Zen Cart, pleae refer to the file of:
docs/read_me_jscript.html

.

16 Jul 2006, 3:02 PM
#4
johnny43 avatar

johnny43

Zen Follower

Join Date:
Feb 2006
Posts:
231
Plugin Contributions:
0

Re: New page with scripts in header

Thanks for pointing in the right direction...
:)

16 Jul 2006, 4:51 PM
#5
johnny43 avatar

johnny43

Zen Follower

Join Date:
Feb 2006
Posts:
231
Plugin Contributions:
0

Re: New page with scripts in header

Wow great...was able to get it going...

need this portion:

"Initialize show content
You can automatically expand content when the pages load. This is done by calling the showHideContent function manually. Example:

<script type="text/javascript"> showHideContent(false,1); // Automatically expand first item </script>

This will automatically show the first item."

I tried as on_load_.js did not work

Tried as <?php echo '<script type="text/javascript"> initShowHideDivs(); showHideContent(false,1); // Automatically expand first item </script>' ?> ...did not work...

Any suggestions on were I'm going wrong ?

16 Jul 2006, 5:52 PM
#6
seethrou avatar

seethrou

Totally Zenned

Join Date:
May 2004
Location:
Hong Kong
Posts:
1,156
Plugin Contributions:
0

Re: New page with scripts in header

For the use of JavaScript in Zen Cart, the basic is to strip both of the header and footer of the normal JavaScript.
And in the body of your jscript_YOUR_JS.js OR on_load_YOUR_JS.js should only contain the JavaScript code's main body.
e.g.
The normal JavaScript code file should contain:

<script type="text/javascript">
...
THE CODE BODY 
...
</script> 

And for use in Zen Cart, only the code body should only be contained:

...
THE CODE BODY 
...

And no header and footer are needed, because Zen Cart will handle the rest. :thumbsup:

You can check the results by viewing of the web page source.

  1. To check wether it loaded in the header or not, for the jscript_YOUR_JS.js
  2. For the on_load, if it loaded, it will also show with the JavaScript codes.

If you use the browser Firefox, get the extension FireBug to help.

What is it?

FireBug lets you explore the far corners of the DOM by keyboard or mouse. All of the tools you need to poke, prod, and monitor your JavaScript, CSS, HTML and Ajax are brought together into one seamless experience, including a debugger, error console, command line, and a variety of fun inspectors.

16 Jul 2006, 6:09 PM
#7
johnny43 avatar

johnny43

Zen Follower

Join Date:
Feb 2006
Posts:
231
Plugin Contributions:
0

Re: New page with scripts in header

Thanks, I did strip out the <script> tags.....

if i view source on the http://www.dhtmlgoodies.com/scripts/show-hide-content-slide/show-hide-content-slide.html the script type="text/javascript">
initShowHideDivs();
showHideContent(false,1); // Automatically expand first item
</script> code is in the body...

if I try on_load.js = showHideContent(false,1); will not work..

I tried on the define_page2"<?php echo '<script type="text/javascript"> initShowHideDivs(); showHideContent(false,1); // Automatically expand first item </script>' ?>" ...did not work...

PS I just started using Firefox....will install FireBug , Thanks

16 Jul 2006, 6:35 PM
#8
seethrou avatar

seethrou

Totally Zenned

Join Date:
May 2004
Location:
Hong Kong
Posts:
1,156
Plugin Contributions:
0

Re: New page with scripts in header

For example,
with refer to your page source, there are a jscript_imagehover.js already loaded. :smile:

<script type="text/javascript" src="includes/templates/template_default/jscript/jscript_imagehover.js"></script>
</head>

This is for the jscript_YOUR_JS.js things, it load before the </head>

And for the on_load things, the page source look like something below:

</head>

<body id="indexBody" onload="function(){
//   var t=new Date().getTime();
  RUZEE.Borders.render();
//   alert('took ' + (new Date().getTime()-t) + ' ms');
};">

<div id="mainWrapper">

It load after the </head>
Do you notice the different?

.

16 Jul 2006, 6:46 PM
#9
seethrou avatar

seethrou

Totally Zenned

Join Date:
May 2004
Location:
Hong Kong
Posts:
1,156
Plugin Contributions:
0

Re: New page with scripts in header

Add more info. for time out of editing for the above post.

The on_laod load after the </head> tag and inside the <body> and </body> tag.

Do you notice the different?

16 Jul 2006, 7:13 PM
#10
johnny43 avatar

johnny43

Zen Follower

Join Date:
Feb 2006
Posts:
231
Plugin Contributions:
0

Re: New page with scripts in header

I just tried
on_load_page2.js:
showHideContent(false,1);
Seems fine in IE but not in firefox...

16 Jul 2006, 7:22 PM
#11
seethrou avatar

seethrou

Totally Zenned

Join Date:
May 2004
Location:
Hong Kong
Posts:
1,156
Plugin Contributions:
0

Re: New page with scripts in header

Then you should find more info in the original site which release the script.
Not every code works both in IE, FF or for all the browsers. :smile:

16 Jul 2006, 7:25 PM
#12
johnny43 avatar

johnny43

Zen Follower

Join Date:
Feb 2006
Posts:
231
Plugin Contributions:
0

Re: New page with scripts in header

In FireFox the div opens , then closes.....
I think the author of the script intented this to be in the body as

<script type="text/javascript"> showHideContent(false,1); // Automatically expand first item </script>

However is does work fin in IE....

16 Jul 2006, 7:25 PM
#13
johnny43 avatar

johnny43

Zen Follower

Join Date:
Feb 2006
Posts:
231
Plugin Contributions:
0

Re: New page with scripts in header

Is there a way just to echo this in the body ?
"<script type="text/javascript">
showHideContent(false,1); // Automatically expand first item
</script>" ?

16 Jul 2006, 7:38 PM
#14
seethrou avatar

seethrou

Totally Zenned

Join Date:
May 2004
Location:
Hong Kong
Posts:
1,156
Plugin Contributions:
0

Re: New page with scripts in header

For the on_load, if do it right, at least it will show some traces of you codes. :smile:

16 Jul 2006, 8:09 PM
#15
johnny43 avatar

johnny43

Zen Follower

Join Date:
Feb 2006
Posts:
231
Plugin Contributions:
0

Re: New page with scripts in header

Well I think I got it...lol
Did a view source on the author's demo page(which worked fine in IE and Firefox) compared to the code they posted...and well got it going...
Thanks for pushing me.....and the help !