未终止的字符串文字

Mic*_*one 0 javascript jquery

再一次,这些错误中的另一个......

我在尝试之前试图解决这个问题,但找不到能解决这个问题的任何问题.

所以我有:( 更新)

<script type="text/javascript"> 
    $(function(){
        $('.episodes').live('click',function(){
            var id = $(this).attr('id').replace('episode_',''),
            width = 730,
            height = 645;

            if(id == 3){
                width = 635;
                height = 790;
            }                   

            ColdFusion.Window.create('Episode_'+id,'','/landing_pages/superhero/episode'+id+'.cfm',{width:width,height:height,center:true,draggable:false,resizable:false,modal:true});
        });
    });
</script>
Run Code Online (Sandbox Code Playgroud)

我已经尝试转义"text\/ javascript"<\/script>,但它要么根本不起作用而不再显示错误,因为它不会将其识别为javascript语句,否则它将继续抛出错误.

Firebug说问题是:var id = $(this).attr('id').replace('episode_',''),,但我没有看到那可能是一个问题.

我正在考虑转移底部的创建方法中的/,但我不认为它会有所作为,因为它显示错误在顶部.

谢谢!

(更新) 我已经用分号问题尝试了所有答案,但它没有用.没有任何影响.还有其他想法吗?

我实际上将它粘贴到CMS中,它将通过SQL然后在我的文章中输出.我不明白为什么会引起问题,但我想这是另一回事.

UPIX UP WITH FIX 错误是使用单引号.不得不将所有单引号更改为双引号.显然,当你将它插入数据库时​​,你必须要做的事情.

最终代码是:

<script type="text/javascript"> 
    $(function(){
        $(".episodes").live("click",function(){
            var id = $(this).attr("id").replace("episode_",""),
            width = 730,
            height = 645;

            if(id == 3){
                width = 635;
                height = 790;
            }                   

            ColdFusion.Window.create("Episode_"+id,"","/landing_pages/superhero/episode"+id+".cfm",{width:width,height:height,center:true,draggable:false,resizable:false,modal:true});
        });
    });
</script>
Run Code Online (Sandbox Code Playgroud)

DrS*_*ove 5

尝试使用分号:

<script type="text/javascript"> 
        $(function(){
            $('.episodes').live('click',function(){
                var id = $(this).attr('id').replace('episode_',''),
                var width = 730,
                var height = 645;

                if(id == 3){
                    width = 635,
                    height = 790;
                }                   

                ColdFusion.Window.create('Episode_'+id,'','/landing_pages/superhero/episode'+id+'.cfm',{width:width,height:height,center:true,draggable:false,resizable:false,modal:true})
            });
        });
    </script>
Run Code Online (Sandbox Code Playgroud)

  • 实际上,在原始代码中的"height"之后有一个分号就足够了.使用"逗号"分隔变量声明就可以了. (2认同)