未终止的字符串文字错误 [英] unterminated string literal error

查看:126
本文介绍了未终止的字符串文字错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



 < script type =text / javascript> 
jQuery(document).ready(function(){
jQuery('head')。append('< script type =text / javascriptsrc =../ wp-includes / js /thickbox.js\"></script>');
});
< / script>

我得到了一个未终止的字符串字面值的错误。

解决方案

这个问题来自您的代码包含< / script> 的事实。这会导致浏览器认为您正在尽早终止您的< script> 标签。如果您将您的代码更改为以下代码,则该代码可以正常工作:

 < script type =text / javascript> 
jQuery(document).ready(function(){
jQuery('head')。append('< script type =text / javascriptsrc =../ wp-includes / js /thickbox.js\"></'+'script>');
});
< / script>

正如您所看到的,上面的代码打破了< / script> 放入'< /'+'script>'中,这样浏览器就不会将它解析为结束标记。 / p>

I have placed the below code inside of the tag.

<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery('head').append('<script type="text/javascript" src="../wp-includes/js/thickbox.js"></script>');    
    });
</script>

I got an error of "unterminated string literal".

解决方案

The problem is coming from the fact that your code includes </script> in it. This is causing the browser to think that you're terminating your <script> tag early. If you change your code to the following, it will work:

<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery('head').append('<script type="text/javascript" src="../wp-includes/js/thickbox.js"></' + 'script>');    
    });
</script>

As you can see, the above code breaks the </script> in your string into '</' + 'script>', so that the browser doesn't parse it as a closing tag.

这篇关于未终止的字符串文字错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆