Javascript字符串操作和innerHtml

时间:2012-03-26 15:14:20

标签: javascript html

我有一个javascript函数,可以将<div>标记的innerHtml更改为在您点击链接时显示视频的代码。

问题是当我用于html的字符串,它以某种方式搞砸了,并且视频没有显示,如果我查看开发人员工具以查看放入的代码是什么,大部分是引号变成了问号,部分代码丢失了吗?

任何人都知道如何修复它?

这是搞乱的字符串:(它是嵌入代码的一部分,但其他部分似乎没问题)

mid1 = ' flashvars="config={"play":{"replayLabel":"","opacity":1},"playlist":[{"url":"http://cdnimages.sorensonmedia.com/c0ffa574B6ccbP46b688a2c9f95914115bbf/7f3101ae-6f7a-11e1-a7d6-22000a1c0595/file-1.jpg","autoPlay":"true"},{"url":"2266d13a-62f8-11e1-9098-123139329b57","autoPlay":true, "fileVersionId":"222bb9b0-62f8-11e1-9098-123139329b57","captionUrl":""},{"url":"http://cdnimages.sorensonmedia.com/c0ffa574B6ccbP46b688a2c9f95914115bbf/7f3101ae-6f7a-11e1-a7d6-22000a1c0595/file-1.jpg","autoPlay":"true"}],"clip":{"provider":"rtmp","accelerated":false,"autoPlay":false,"fadeInSpeed":1000,"scaling":"fit","url":""},"canvas":{"backgroundColor":"#000000","backgroundGradient":"low"},"logo":{"left":15,"top":15,"opacity":1,"displayTime":4,"fullscreenOnly":false,"url":"","linkUrl":"","linkWindow":"_blank"},"plugins":{"rtmp":{"url":"http://static.cdn.360.sorensonmedia.com/1/flash/plugin.gm.rtmp-3.1.5.0.swf"},"sorenson360":{"apiPath":"http://360.sorensonmedia.com/api","url":"http://static.cdn.360.sorensonmedia.com/1/flash/plugin.gm.sorenson-3.2.2.0.swf"},"controls":{"apiPath":"http://360.sorensonmedia.com/api","url":"http://static.cdn.360.sorensonmedia.com/1/flash/flowplayer.controls-3.2.2.2.1.swf","autoHide":"never","hideDelay":4000,"borderRadius":0,"volumeSliderGradient":"none","bufferGradient":"none","tooltipTextColor":"#ffffff","progressColor":"#1e5576","bufferColor":"#020c13","progressGradient":"medium","backgroundColor":"#222222","sliderColor":"#000000","volumeSliderColor":"#000000","buttonColor":"#363636","durationColor":"#ffffff","timeColor":"#6F030A","sliderGradient":"none","buttonOverColor":"#728B94","backgroundGradient":"none","tooltipColor":"#5F747C","timeBgColor":"#363636","height":20,"opacity":1,"play":true,"scrubber":true,"volume":true,"stop":false,"mute":true,"time":true,"fullscreen":true,"playerStyle":"static","embed":false,"email":true,"width":"100pct","bottom":0,"playerSkin":2},"playListView":null},"playerId":"videoPlayer","screen":{"bottom":10},"onLoad":""}" ';

如果我复制代码,那就是

<embed width="100%" height="100%" id="videoPlayer_api" src="http://static.cdn.360.sorensonmedia.com/1/flash/flowplayer-3.2.2.swf" type="application/x-shockwave-flash" style="outline-width: medium; outline-style: none; outline-color: invert;" wmode="transparent" allowfullscreen="true" allowscriptaccess="always" quality="high" cachebusting="false" bgcolor="#000000" flowplayer.controls-3.2.2.2.1.swf?,?autoHide?:?never?,?hideDelay?:4000,?borderRadius?:0,?volumeSliderGradient?:?none?,?bufferGradient?:?none?,?tooltipTextColor?:?#ffffff?,?progressColor?:?#1e5576?,?bufferColor?:?#020c13?,?progressGradient?:?medium?,?backgroundColor?:?#222222?,?sliderColor?:?#000000?,?volumeSliderColor?:?#000000?,?buttonColor?:?#363636?,?durationColor?:?#ffffff?,?timeColor?:?#6F030A?,?sliderGradient?:?none?,?buttonOverColor?:?#728B94?,?backgroundGradient?:?none?,?tooltipColor?:?#5F747C?,?timeBgColor?:?#363636?,?height?:20,?opacity?:1,?play?:true,?scrubber?:true,?volume?:true,?stop?:false,?mute?:true,?time?:true,?fullscreen?:true,?playerStyle?:?static?,?embed?:false,?email?:true,?width?:?100pct?,?bottom?:0,?playerSkin?:2},?playListView?:null},?playerId?:?videoPlayer?,?screen?:{?bottom?:10},?onLoad?:??}?="" flash="" 1="" static.cdn.360.sorensonmedia.com="" api?,?url?:?http:="" 360.sorensonmedia.com="" plugin.gm.sorenson-3.2.2.0.swf?},?controls?:{?apiPath?:?http:="" plugin.gm.rtmp-3.1.5.0.swf?},?sorenson360?:{?apiPath?:?http:="" file-1.jpg?,?autoPlay?:?true?}],?clip?:{?provider?:?rtmp?,?accelerated?:false,?autoPlay?:false,?fadeInSpeed?:1000,?scaling?:?fit?,?url?:??},?canvas?:{?backgroundColor?:?#000000?,?backgroundGradient?:?low?},?logo?:{?left?:15,?top?:15,?opacity?:1,?displayTime?:4,?fullscreenOnly?:false,?url?:??,?linkUrl?:??,?linkWindow?:?_blank?},?plugins?:{?rtmp?:{?url?:?http:="" 7f3101ae-6f7a-11e1-a7d6-22000a1c0595="" c0ffa574B6ccbP46b688a2c9f95914115bbf="" cdnimages.sorensonmedia.com="" file-1.jpg?,?autoPlay?:?true?},{?url?:?2266d13a-62f8-11e1-9098-123139329b57?,?autoPlay?:true,?fileVersionId?:?222bb9b0-62f8-11e1-9098-123139329b57?,?captionUrl?:??},{?url?:?http:="" play?:{?replayLabel?:??,?opacity?:1},?playlist?:[{?url?:?http:="" flashvars="config={"/>

1 个答案:

答案 0 :(得分:0)

我认为你需要HTML编码你想要插入的字符串。

查看escape function