DIV CSS 佈局教程網

JS encodeURI 函數:URI 編碼與保留字元
編輯:關於JavaScript     

encodeURI 作用

encodeURI 可將字串編碼為 URI,常用於處理包含中文或空格的網址。

encodeURI("https://example.com/My first/");
// https://example.com/My%20first/

保留字元

encodeURI 不會編碼 ASCII 字母、數字,以及 - _ . ! ~ * ' ( ) 等符號。它也不會編碼 URI 中具有特殊意義的 ; / ? : @ 與 = + $ #。

encodeURIComponent

若需要編碼 URI 元件,例如查詢參數值,建議使用 encodeURIComponent,避免特殊符號被保留而影響解析。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved