Share via


encodeURIComponent 方法

更新:2007 年 11 月

回傳已編碼成有效的統一資源識別元 (URI) 元件的字串。

 function encodeURIComponent(encodedURIString : String) : String

引數

  • encodedURIString
    必要項。一個代表已編碼之 URI 元件的字串。

備註

encodeURIComponent 方法會傳回已編碼的 URI。如果將結果傳給 decodeURIComponent,就會傳回原始字串。因為 encodeURIComponent 方法會為所有字元編碼,請特別注意字串是否表示路徑,像是 /folder1/folder2/default.html。將會對斜線字元進行編碼,若以此編碼做為要求傳至 Web 伺服器,則不會有效。如果字串包含不止一個單一 URI 元件的話,應使用 encodeURI 方法。

需求

5.5 版

套用至:

Global 物件

請參閱

參考

decodeURI 方法

decodeURIComponent 方法