添加jquery后,Prestashop不显示页面

时间:2013-04-06 11:08:10

标签: jquery html prestashop

我有最新的Presta商店。当我添加上面的代码

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
jQuery(document).ready(function(){
    if(catapultReadCookie("catAccCookies")){//If the cookie has been set
        jQuery("#catapult-cookie-bar").hide();
        jQuery("html").css("margin-bottom","0");
    }
});
</script>

从工具/ smarty /编译网站删除缓存不显示。我不知道为什么?谢谢你的帮助。

2 个答案:

答案 0 :(得分:0)

试试这样:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
jQuery(document).ready(function(){
    var data = catapultReadCookie("catAccCookies");
    if(data != null && data !== 'undefined'){//If the cookie has been set
        jQuery("#catapult-cookie-bar").hide();
        jQuery("html").css("margin-bottom","0");
    }
});
</script>

答案 1 :(得分:0)

由于prestashop使用smarty作为模板语言,而smarty使用大括号样式,因此您无法将嵌入的javascript添加到模板文件中。

要将javascript添加到模板文件,它应该包含在{literal} .... {/ literal} smarty标记中。你的代码应该是这样的:

{literal}

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
jQuery(document).ready(function(){
if(catapultReadCookie("catAccCookies")){//If the cookie has been set
    jQuery("#catapult-cookie-bar").hide();
    jQuery("html").css("margin-bottom","0");
}
});
</script> 

 {/literal}

对于文字,请仔细阅读

http://www.smarty.net/docsv2/en/language.function.literal

谢谢

相关问题