關於javascript中encodeURI和decodeURI的使用方法
一、基本概念
encodeURI和decodeURI是成對來使用的,因爲瀏覽器的`地址欄有中文字符的話,可以會出現不可預期的錯誤,所以可以encodeURI把非英文字符轉化爲英文編碼,decodeURI可以用來把字符還原回來。encodeURI方法不會對下列字符進行編碼:":"、"/"、";" 和 "?",encodeURIComponent方法可以對這些字符進行編碼。
decodeURI()方法相當於de(URIString, "UTF-8");
encodeURI()方法相當於de(URIString, "UTF-8");
二、例子
複製代碼 代碼如下:
var uriStr = "張三&num=001 zs";
var uriec = encodeURI(uriStr);
e("編碼後的" + uriec);
var uridc = decodeURI(uriec);
e("解碼後的" + uridc);
編碼後的
解碼後的張三&num=001 zs
相關文章
-
Should Private Cars Be Encouraged in China高中英語作文
with the rapid development of economy in china, the number of people who own private cars is rising day after day. quite different views eist as to this e is no doubt that private cars have been playi -
託福英語寫作範文:Examinations exert a pernicious influence on educat
We might marvel at the progress made in every field of study, but the methods of testing a person’s knowledge and ability remain as primitive as ever they were. It really is extraordinary that after -
英語閱讀:VIT declines to acquire Ang Mo Kio property
像在北方地區大棚內的黑坑較爲多見,自然不會受到多少自然因素的影響,可遮風擋雨,現在的垂釣環境也是越來越好內部還設有地暖、大燈,大大提高了釣魚的舒適度。冬季來臨,氣溫突降,越來越多的北方釣友開始轉戰大棚,高手在線嘉賓 -
九年級《unit 6 I like music that I can dance to. Period2》評課稿
朱老師是早上的第三節課,上的內容九年級unit 6 I like music that I can dance to. Period2, 這是一堂新授課,圍繞的主題是音樂,表達自己對音樂的喜好以及原因,主要學習由that 和who引導的定語從句。1. 朱老師教學基本功 -
英語閱讀:Covergirl unveils empowering brand update
It may have been founded 60 years ago old, but US cosmetics giant Covergirl is proving that you're never too old to reinvent yourself.The Coty-owned makeup brand, which has been attracting attenti -
四級作文:Create a Conservation-Oriented Campus
四級作文:Create a Conservation-Oriented Campus,四級作文:Create a Conservation-Oriented Campus範文,免費提供給大家交流參考! Create a Conservation-Oriented Campus1.建設節約型校園十分重要2.原因是…&he -
Chinas Liu to seek injury advice in US soon英語作文
一學期的體育部工作即將接近尾聲,我們的所有工作有什麼成效,有什麼經驗教訓,來寫一份工作總結吧。下面是小編蒐集整理的2019年體育部上學期個人工作總結,歡迎閱讀。更多資訊請繼續關注個人工作總結欄目!2019年體育部上學 -
Efforts Urged to Improve Womens Reproductive Health英語閱讀
Efforts Urged to Improve Women's Reproductive HealthParliamentarians from over 100 countries are being urged to take action in improving women's reproductive health ahead of the 2015 deadline -
jQuery中的read和JavaScript中的onload函數的區別在哪
在JavaScript中,onload函數是最經常使用的,幾乎涉及到JavaScript的童鞋都少不了要接觸它。這個函數的作用就是等待網頁完全裝載完了以後再去執行代碼塊內的語句,因爲按照文檔流的執行順序,通常用於頭部加載JavaScript的` -
A Lifeguard at Johns Beach Saved a Drowning Child,A Lifeguar英語作文
在生活、工作和學習中,大家一定都接觸過作文吧,作文是人們把記憶中所存儲的有關知識、經驗和思想用書面形式表達出來的記敘方式。爲了讓您在寫作文時更加簡單方便,下面是小編收集整理的'A Lifeguard at Johns Beach Sav