简体   繁体   中英

Adding JS to Magento product page

I am trying to add a couple of JS to Magento. I am trying to modify the "product-shop" so that it stays fixed when scrolling down. Here is a Fiddle of what I am trying to do http://jsfiddle.net/PXadg/

   `$(document).ready(function() {
        $('#summary').scrollToFixed({
            marginTop:
                $('.header').outerHeight() + 10,
            limit:
                $('.footer').offset().top -
                $('#summary').outerHeight() -
                10
        });
    });`

Can anyone help me by telling me where I need to make changes in XML or phml files so that Magento runs this scripts?

Regards,

Add this to your xml file

 <catalog_product_view>
         <reference name="head">
                <action method="addJs"><script>yourscript.js</script></action>
            </reference>
 </catalog_product_view>

make sure to clear cache after changing this. Also clear your browser history.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM