单击按钮时无法预览 js 嵌入代码
我要求用户将js(以及任何)嵌入代码放入textarea中,例如以下js嵌入代码提交到textarea中,
<script type='text/javascript' src='http://video.boston.cbslocal.com/global/video/videoplayer.js?rnd=275172;hostDomain=video.boston.cbslocal.com;playerWidth=320;playerHeight=240;isShowIcon=true;clipId=6326565;flvUri=;partnerclipid=;adTag=News;advertisingZone=CBS.BOSTON%252Fworldnowplayer;enableAds=true;landingPage=;islandingPageoverride=false;playerType=STANDARD_EMBEDDEDscript;controlsType=fixed'></script>
textarea旁边有一个预览按钮,单击该按钮我可以获得文本区域的内容并将其分配给隐藏div 'id_bm_embed_view_div' 并稍后显示此 div,如:
$('#id_bm_embed_view_div').html(textarea contet);
$('#id_bm_embed_view_div').show();
twitter 和 youtube 嵌入代码似乎工作正常,显示正确的预览,但我不适合 js 嵌入代码,我在这里缺少什么?
例如,如果我输入以下嵌入代码,我将获得嵌入代码的正确预览
<!-- Generated by EmbeVi (http://www.embevi.com) --> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" type="application/x-shockwave-flash" width="425" height="344"> <param name="movie" value="http://www.youtube.com/v/R4j8p6zlFHs&f=videos&app=youtube_gdata" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><param name="pluginspage" value="http://get.adobe.com/flashplayer/" /> <embed type="application/x-shockwave-flash" src="http://www.youtube.com/v/R4j8p6zlFHs&f=videos&app=youtube_gdata" width="425" height="344" wmode="transparent" allowScriptAccess="always" pluginspage="http://get.adobe.com/flashplayer/" flashvars="" quality="high" allowfullscreen="true" loop="false" autoplay="false" autostart="false" scale="exactfit" align="middle" /> </object>
I am asking user to put js (well any) embed code into a textarea e.g. the following js embed code is submitted into textarea
<script type='text/javascript' src='http://video.boston.cbslocal.com/global/video/videoplayer.js?rnd=275172;hostDomain=video.boston.cbslocal.com;playerWidth=320;playerHeight=240;isShowIcon=true;clipId=6326565;flvUri=;partnerclipid=;adTag=News;advertisingZone=CBS.BOSTON%252Fworldnowplayer;enableAds=true;landingPage=;islandingPageoverride=false;playerType=STANDARD_EMBEDDEDscript;controlsType=fixed'></script>
there is preview button next to textarea on click of which I get the contents of the text area and assign it to hidden div 'id_bm_embed_view_div' and later showing this div like:
$('#id_bm_embed_view_div').html(textarea contet);
$('#id_bm_embed_view_div').show();
twitter and youtube embed code seems works fine, shows proper preview, but I don't get it right for js embed code, what I am missing here?
e.g. if I put following embed code I get the proper preview of the embed code
<!-- Generated by EmbeVi (http://www.embevi.com) --> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" type="application/x-shockwave-flash" width="425" height="344"> <param name="movie" value="http://www.youtube.com/v/R4j8p6zlFHs&f=videos&app=youtube_gdata" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><param name="pluginspage" value="http://get.adobe.com/flashplayer/" /> <embed type="application/x-shockwave-flash" src="http://www.youtube.com/v/R4j8p6zlFHs&f=videos&app=youtube_gdata" width="425" height="344" wmode="transparent" allowScriptAccess="always" pluginspage="http://get.adobe.com/flashplayer/" flashvars="" quality="high" allowfullscreen="true" loop="false" autoplay="false" autostart="false" scale="exactfit" align="middle" /> </object>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您应该对提交的数据中的任何
/
进行转义。我尝试了这些例子:
这不起作用。它在 div 中打印
");
。但这是有效的:
希望有帮助。
I think you should scape any
/
in your submitted data.I tried these examples:
This doesn't work. It prints
");
in div.But this works:
Hope it helps.