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)文章
使用svg實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘效果
這篇文章主要為大家詳細(xì)介紹了如何使用svg實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-07-07JS生成不重復(fù)隨機(jī)數(shù)組的函數(shù)代碼
這篇文章主要介紹了JS生成不重復(fù)隨機(jī)數(shù)組的函數(shù)代碼,需要的朋友可以參考下2014-06-06關(guān)于js函數(shù)解釋(包括內(nèi)嵌,對(duì)象等)
下面小編就為大家?guī)硪黄P(guān)于js函數(shù)解釋(包括內(nèi)嵌,對(duì)象等) 。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-11-11jQuery實(shí)現(xiàn)可收縮展開的級(jí)聯(lián)菜單實(shí)例代碼
這篇文章主要是對(duì)利用jQuery實(shí)現(xiàn)可收縮展開的級(jí)聯(lián)菜單的實(shí)例代碼進(jìn)行了詳細(xì)的介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助2013-11-11javascript實(shí)現(xiàn)控制瀏覽器全屏
這篇文章主要介紹了javascript實(shí)現(xiàn)控制瀏覽器全屏的代碼分享給大家,十分的實(shí)用,有需要的小伙伴可以參考下。2015-03-03javascript中日期函數(shù)new Date()的瀏覽器兼容性問題
這篇文章主要介紹了javascript中日期函數(shù)new Date()的瀏覽器兼容性問題,需要的朋友可以參考下2015-09-09