繁体   English   中英

如何在javascript中放置var url?

[英]How to put var url in javascript?

我在php中做了这样的声明(取自js脚本文件中的WordPress路径url ):

<script type="text/javascript">
    var templateurl = "<?php bloginfo('template_url') ?>";
</script>

然后我在我的javascript(myjava.js)中有这个代码:

init : function(ed, url) {

        ed.addCommand('mcearrow_shortcodes', function() {
            ed.windowManager.open({
                file : url + '/interface.php',
                width : 410 + ed.getLang('arrow_shortcodes.delta_width', 0),
                height : 250 + ed.getLang('arrow_shortcodes.delta_height', 0),
                inline : 1
            }, {
                plugin_url : url
            });
        });


        ed.addButton('arrow_shortcodes', {
            title : 'arrow_shortcodes.desc',
            cmd : 'mcearrow_shortcodes',
            image : url + '/btn.png'
        });


        ed.onNodeChange.add(function(ed, cm, n) {
            cm.setActive('arrow_shortcodes', n.nodeName == 'IMG');
        });
    }, 

我想用templateurl更改所有'url +',我试图使用它:

 file : templateurl + '/includes/scripts/interface.php'

但它不起作用。 它不会加载interface.php。 但是,如果我使用'url +',则interface.php会被完美加载。 问题是,我想把我的interface.php放在不同的文件夹中。 不在myjava.js所在的同一文件夹中。

使用我的templateurl变量的正确方法是什么?

非常感谢!

templateurl有价值吗? 请检查一下。 你正在分配php变量,所以请回复它。

<script type="text/javascript">
    var templateurl = "<?php echo bloginfo('template_url') ?>";
</script>

暂无
暂无

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

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