Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,303
    Plugin Contributions
    1

    Default another on_load jscript question

    Running v1.50 - on a local server, and read the following recommended resources to try and get 'on_load' to work:

    Documents in the Zen Cart default install package.
    docs/read_me_jscript.html
    docs/read_me_onload.html

    And more in the wiki
    Javascript
    I have successfully added an image slider to the main page of my site by:

    adding jscript_jquery.nivo.slider.js into includes\templates\MY_TEMPLATE\jscript folder

    adding stylesheet_nivo-slider.css into includes\templates\MY_TEMPLATE\css folder

    added a <div> in tpl_main_page.php calling up the images to use in the slider (probably shouldn't have used this file but included 'if($this_is_home_page)', and it seemed a good idea at the time).

    added the following code, after the above <div> :

    Code:
    <script type="text/javascript">
    $(window).load(function() {
        $('#slider').nivoSlider();
    });
    </script>
    and, included in html_header.php this code

    PHP Code:
    <link rel="stylesheet" href="stylesheet_nivo-slider.css" type="text/css" media="screen" />
    <
    script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
    <script src="jscript_jquery.nivo.slider.js" type="text/javascript"></script> 
    I have left the external link to jquery.min.js whilst testing.

    All seems to work ok.

    Rather than having the code in html_header.php I wanted to use the on_load system. So I created a file on_load_nivo.slider.js in includes\templates\MY_TEMPLATE\jscript\on_load\ folder with exactly the following code:

    Code:
    <link rel="stylesheet" href="stylesheet_nivo-slider.css" type="text/css" media="screen" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
    <script src="jscript_jquery.nivo.slider.js" type="text/javascript"></script>
    deleted the code I had inserted in html_header.php and expected it to work. No joy

    Any ideas as to what I have done wrong?

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: another on_load jscript question

    The on_load "system" to which you refer doesn't load a bunch of HTML such as you're proposing. It simply inserts a statement to appear inside the <body> tag's onload="xxxxx" attribute.

    You're stuffing HTML into a .js file. They're completely different animals.

    The stuff you're putting in your on_load_nivo.slider.js file is probably best put into an /includes/templates/your_template/jscript/jscript.nivo.php file instead.


    In my estimation this issue has nothing to do with on_load at all.
    .

    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.

 

 

Similar Threads

  1. on_load on Home Page Only?
    By DivaVocals in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 26 Sep 2009, 03:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg