How to load javascript on specific page only

Possible duplicate : How to include Javascript in xml-document?

How would I load a javascript file only only checkout pages? We are using onepage checkout. I have tried adding

            <action method="addJs">
                <script>myscript.js</script>
            </action>

To various places on checkout.xml with no success

One thought on “How to load javascript on specific page only”

  1. The page frame for the onepage checkout is loaded in the initial action. Try something like this:

    <checkout_onepage_index>
        <reference name="head">  
             <action method="addItem"><type>skin_js</type><name>js/myscript.js</name></action>
        </reference>
    </checkout_onepage_index>
    

    Then place your script in your skin directory under /js.

    Hope that helps!

    Thanks,
    Joe

Leave a Reply

Your email address will not be published. Required fields are marked *