dar*_*ark 2 javascript string uploadify
我有一个php脚本,它在我的服务器上传mp3文件.我使用'uploadify'.有一个事件'onSelect'(文档),在文件上传时调用.使用它我想在每个文件上传后动态刷新播放列表.
但是我在'onselect'字段中的函数抛出了一个错误'unterminated string literal'.经过长时间的搜索,我将我的单行函数改为多行(为方便起见,这里添加了分隔线)并在双引号之前添加斜杠.
function() {$('#response').append("
<script type=\"text/javascript\">
var flashvars = {url:'./media/audio/users/126/md6xs4cv8ks0.mp3',artist:'Undef', track:'Undef', duration:''};
var Params = {};
var attributes = {};
swfobject.embedSWF(\"min.swf\", \"myAlternativeContent1\", \"320\", \"40\", \"9.0.0\", false, flashvars, params, attributes);
</script>
<div id="myAlternativeContent1">
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
</div>
Run Code Online (Sandbox Code Playgroud)
小智 5
与其他答案相反,字符串文字可以包含换行符,它们只需要使用反斜杠进行转义,如下所示:
var string = "hello\
world!";
Run Code Online (Sandbox Code Playgroud)
但是,这不会在字符串中创建换行符,因为它必须是显式\n转义序列.这在技术上会成为helloworld.干
var string = "hello"
+ "world"
Run Code Online (Sandbox Code Playgroud)
会更清洁
| 归档时间: |
|
| 查看次数: |
8834 次 |
| 最近记录: |