encodeURIComponent的重新學(xué)習(xí)
encodeURIComponent將所有的非字母數(shù)字的字符轉(zhuǎn)換為瀏覽器可理解的UTF-8編碼。
跟她對(duì)應(yīng)的是encodeURI,一個(gè)是將URI轉(zhuǎn)換一部分,一個(gè)是全部轉(zhuǎn)換
示例:
鏈接:http://www.wrox.com/illegal value.htm#start
encodeURIComponent結(jié)果:http%3A%2F%2Fwww.wrox.com%2Fillegal%20value.htm%23start
encodeURI的結(jié)果:http://www.wrox.com/illegal%20value.htm#start
與上面兩個(gè)對(duì)應(yīng)的是decodeURI和decodeURIComponent,不多做贅述。