欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js FLASH幻燈片字符串中有連接符&的處理方法

 更新時(shí)間:2012年03月01日 15:23:15   作者:  
一般情況下我們?cè)贔LASH幻燈片字符串中有連接符時(shí)點(diǎn)擊鏈接就會(huì)不正常,造成鏈接中的參數(shù)丟失,那么就需要用encodeURIComponent來對(duì)鏈接地址進(jìn)行編碼
復(fù)制代碼 代碼如下:

<script type="text/javascript">
varconfig='6|0xffffff|0x0099ff|50|0xffffff|0x0099ff|0x000000';
varfiles='http://www.dbjr.com.cn/bbs/attachments/month_1001/10010519247f1786dc556829c5.jpg|http://www.dbjr.com.cn/bbs/attachments/month_1001/1001060845f046a796b52d112f.jpg|http://www.dbjr.com.cn/bbs/attachments/month_1001/10010812174b26936d6961598a.png|http://www.dbjr.com.cn/bbs/attachments/month_1001/1001061531c89399912d217be4.png|http://www.dbjr.com.cn/bbs/ttachments/month_1001/1001071315a59155ffb750a427.jpg|http://www.dbjr.com.cn/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年P(guān)PT模板|【模板參選】中國移動(dòng)援博2009年P(guān)PT模板|超酷CIG企業(yè)演示PPT|急求:立體的對(duì)號(hào)和錯(cuò)號(hào)|2010年標(biāo) 新|畫軸開啟、書法動(dòng)畫、畫軸閉合';
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.dbjr.com.cn/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.dbjr.com.cn/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>

經(jīng)過測(cè)試可以單獨(dú)對(duì)links進(jìn)行處理即可
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 對(duì)文字進(jìn)行編碼涉及3個(gè)函數(shù):escape,encodeURI,encodeURIComponent,相應(yīng)3個(gè)解碼函數(shù):unescape,decodeURI,decodeURIComponent
1、 傳遞參數(shù)時(shí)需要使用encodeURIComponent,這樣組合的url才不會(huì)被#等特殊字符截?cái)唷?
例如:
2、 進(jìn)行url跳轉(zhuǎn)時(shí)可以整體使用encodeURI
例如:Location.href="/encodeURI"("http://www.dbjr.com.cn/s?word=百度&ct=21");
3、 js使用數(shù)據(jù)時(shí)可以使用escape
例如:搜藏中history紀(jì)錄。
4、 escape對(duì)0-255以外的unicode值進(jìn)行編碼時(shí)輸出%u****格式,其它情況下escape,encodeURI,encodeURIComponent編碼結(jié)果相同。
最多使用的應(yīng)為encodeURIComponent,它是將中文、韓文等特殊字符轉(zhuǎn)換成utf-8格式的url編碼,所以如果給后臺(tái)傳遞參數(shù)需要使用encodeURIComponent時(shí)需要后臺(tái)解碼對(duì)utf-8支持(form中的編碼方式和當(dāng)前頁面編碼方式相同)
escape不編碼字符有69個(gè):*,+,-,.,/,@,_,0-9,a-z,A-Z
encodeURI不編碼字符有82個(gè):!,#,$,&,\',(,),*,+,,,-,.,/,:,;,=,?,@,_,~,0-9,a-z,A-Z
encodeURIComponent不編碼字符有71個(gè):!, \',(,),*,-,.,_,~,0-9,a-z,A-Z

相關(guān)文章

最新評(píng)論