encodeURIComponent方法()函數(shù)對統(tǒng)一資源標(biāo)識符(URI)組件進(jìn)行編碼。
注意:使用encodeURIComponent()函數(shù)可解碼統(tǒng)一資源標(biāo)識符(URI)組件。
encodeURIComponent(uri)
var uri = "http://example.com/nxm.php?s=шеллы"; var en = encodeURIComponent(uri);
所有瀏覽器都完全支持encodeURIComponent()函數(shù):
| Function | ![]() | ![]() | ![]() | ![]() | ![]() |
| encodeURIComponent() | 是 | 是 | 是 | 是 | 是 |
| 參數(shù) | 描述 |
|---|---|
| uri | 要編碼的URI組件 |
| 返回值: | 代表給定URI組件的編碼版本的新字符串 |
|---|---|
| JavaScript版本: | ECMAScript 1 |