js FLASH幻灯片字符串中有连接符&的处理方法


复制代码 代码如下:

<script type="text/javascript">
varconfig='6|0xffffff|0x0099ff|50|0xffffff|0x0099ff|0x000000';
varfiles='http://www.phpstudy.net/bbs/attachments/month_1001/10010519247f1786dc556829c5.jpg|http://www.phpstudy.net/bbs/attachments/month_1001/1001060845f046a796b52d112f.jpg|http://www.phpstudy.net/bbs/attachments/month_1001/10010812174b26936d6961598a.png|http://www.phpstudy.net/bbs/attachments/month_1001/1001061531c89399912d217be4.png|http://www.phpstudy.net/bbs/ttachments/month_1001/1001071315a59155ffb750a427.jpg|http://www.phpstudy.net/bbs/attachments/month_1001/1001071933febe3e795de1dcdb.jpg';
varlinks='PageView.asp?id=36&cid=42&Lid=34|PageView.asp?id=36&cid=42|http://www.renren.com|http://www.ifeng.com/|http://www.tudou.com/|http://www.http://www.skycn.com/';
vartexts='【模板参选】华为2009年PPT模板|【模板参选】中国移动援博2009年PPT模板|超酷CIG企業演示PPT|急求:立体的对号和错号|2010年标 新|画轴开启、书法动画、画轴闭合';
varflashvars=[
'config='+encodeURIComponent(config)
,'files='+encodeURIComponent(files)
,'links='+encodeURIComponent(links)
,'texts='+encodeURIComponent(texts)
].join("&");
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100%" height="198">');
document.write('<param name="movie" value="http://www.phpstudy.net/bbs/images/xshow/focus.swf" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="menu" value="false" />');
document.write('<param name="wmode" value="transparent" />');
document.write('<param name="flashvars" value="'+flashvars+'" />');
document.write('<embed src="http://www.phpstudy.net/bbs/images/xshow/focus.swf" wmode="opaque" flashvars="'+flashvars+'" menu="false" quality="high" width="100%" height="198" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');
</script>

经过测试可以单独对links进行处理即可
document.write('<param name="FlashVars" value="pics='+pics522+'&links='+encodeURIComponent(links522)+'&texts='+texts522+'&borderwidth='+focus_width522+'&borderheight='+focus_height522+'&textheight='+text_height522+'">');
js编码之 encodeURIComponent

js 对文字进行编码涉及3个函数:escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decodeURIComponent
1、 传递参数时需要使用encodeURIComponent,这样组合的url才不会被#等特殊字符截断。
例如:
2、 进行url跳转时可以整体使用encodeURI
例如:Location.href="/encodeURI"("http://www.phpstudy.net/s?word=百度&ct=21");
3、 js使用数据时可以使用escape
例如:搜藏中history纪录。
4、 escape对0-255以外的unicode值进行编码时输出%u****格式,其它情况下escape,encodeURI,encodeURIComponent编码结果相同。
最多使用的应为encodeURIComponent,它是将中文、韩文等特殊字符转换成utf-8格式的url编码,所以如果给后台传递参数需要使用encodeURIComponent时需要后台解码对utf-8支持(form中的编码方式和当前页面编码方式相同)
escape不编码字符有69个:*,+,-,.,/,@,_,0-9,a-z,A-Z
encodeURI不编码字符有82个:!,#,$,&,\',(,),*,+,,,-,.,/,:,;,=,?,@,_,~,0-9,a-z,A-Z
encodeURIComponent不编码字符有71个:!, \',(,),*,-,.,_,~,0-9,a-z,A-Z
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3