【问题标题】:cms made simple how to include javascript in my templatecms 让如何在我的模板中包含 javascript 变得简单
【发布时间】:2011-08-06 05:29:51
【问题描述】:

您好,我有点卡在这里,我似乎无法在我的 cmsms 模板中包含 javascript 文件。

<script src="js/slides.min.jquery.js"></script>
<script>
    $(function(){
        $('#slides').slides({
            preload: true,
            preloadImage: 'img/loading.gif',
            play: 5000,
            pause: 2500,
            hoverPause: true
        });
    });
</script>

此代码不起作用,它既不包含 js/slides.min.jquery.js 也不运行脚本,谁能解释一下 javascript 是如何包含在 cmsms 模板中的。 .

【问题讨论】:

    标签: javascript include cmsmadesimple


    【解决方案1】:

    您需要在{literal} 标签中包含javascript,以避免cmsms 尝试解析它。这是一个示例(来自我的一个网站),其中包括 Google 分析 javascript。

    {literal}
    <script type="text/javascript">
    
     var _gaq = _gaq || [];
     _gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
     _gaq.push(['_trackPageview']);
    
     (function() {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') +     '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
     })();
    
    </script>
    {/literal}
    

    【讨论】:

    • 我知道这会很容易。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-14
    • 2015-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多