简体   繁体   English

将 JS 添加到 Magento 产品页面

[英]Adding JS to Magento product page

I am trying to add a couple of JS to Magento.我正在尝试向 Magento 添加几个 JS。 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/这是我正在尝试做的事情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?任何人都可以通过告诉我需要在 XML 或 phml 文件中进行更改的位置来帮助我,以便 Magento 运行此脚本吗?

Regards,问候,

Add this to your xml file将此添加到您的 xml 文件中

 <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.还要清除浏览器历史记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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