js FLASH幻灯片字符串中有连接符&的处理方法
2012-03-01 00:00
218 查看
<script type="text/javascript"> varconfig='6|0xffffff|0x0099ff|50|0xffffff|0x0099ff|0x000000'; varfiles='http://www.jb51.net/bbs/attachments/month_1001/10010519247f1786dc556829c5.jpg|http://www.jb51.net/bbs/attachments/month_1001/1001060845f046a796b52d112f.jpg|http://www.jb51.net/bbs/attachments/month_1001/10010812174b26936d6961598a.png|http://www.jb51.net/bbs/attachments/month_1001/1001061531c89399912d217be4.png|http://www.jb51.net/bbs/ttachments/month_1001/1001071315a59155ffb750a427.jpg|http://www.jb51.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.jb51.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.jb51.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.jb51.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
相关文章推荐
- js FLASH幻灯片字符串中有连接符&的处理方法
- html之js字符串处理方法
- js 去除字符串全部空格 去除字符串前后空格 名字中姓和名之间存在空格简便处理方法
- JS常用字符串处理方法应用总结
- js 将用连接符连接的英文字符串转换成驼峰命名的三种方法
- js中方法调用时,参数未被识别成字符串,而被当做对象来处理
- JS中处理字符串的方法
- JS一些常用的处理字符串的方法
- js前端页面,对string字符串的处理函数和方法
- js弹出层包含flash 不能关闭隐藏的2种处理方法
- js弹出层包含flash 不能关闭隐藏的2种处理方法
- JS经常使用字符串处理方法总结
- 【写一个自己的js库】 3.添加几个处理字符串的方法
- JS实现FLASH幻灯片图片切换效果的方法
- JS--处理字符串的方法
- 处理字符串的一些js/jq方法(去除HTML,去除空格,计算真实长度,截取中英文字符)
- JS常用字符串处理方法总结
- js拼接字符串时,字符串的事件参数需要传对象或对象数组的处理方法
- JS常用字符串处理方法应用总结
- JS实现FLASH幻灯片图片切换效果的方法