2010-04-09 30 views
0

我有以下的javascript函数:置字符串

<script type="text/javascript"> 
    function quickCardRegister_OnCompleteSave() { 

     publishContent('This is a description',#{imagePath},'http://www.lala.com'); 
    } 
</script> 

的ImagePath的变量被填充值:http://localhost/img/30_w130px.gif

我在下面的脚本错误:在参数列表丢失)

publishContent('这是一个描述',http://localhost/img/30_w130px.gif,'http://www.lala.com');

如何将http://localhost/img/30_w130px.gif用引号括起来?

感谢

回答

0

好像你在某些类型的模板语言..

有你#{}的ImagePath尝试报价?

<script type="text/javascript"> 
function quickCardRegister_OnCompleteSave() { 

    publishContent('This is a description','#{imagePath}','http://www.lala.com'); 
} 
</script> 
0

快来看看年底刚刚闭幕脚本标签前的功能缺失的“}”?

<script type="text/javascript"> 
    function quickCardRegister_OnCompleteSave() { 

     publishContent('This is a description',#{imagePath},'http://www.lala.com'); 
    } 
</script> 
0

尝试

publishContent('This is a description','"' + #{imagePath} + '"','http://www.lala.com'); 
0

你缺少}您的功能以及+ JavaScript的串联:

<script type="text/javascript"> 
    function quickCardRegister_OnCompleteSave() { 

     publishContent('This is a description' + #{imagePath} + 'http://www.lala.com'); 
    } 
</script> 

而且我认为#{imagePath}东西,你会动态替换。

+0

忘了它....这不是问题,它是一个错字粘贴在这里。 – 2010-04-09 08:57:48