decodeURI()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
decodeURI()
関数は、encodeURI()
関数あるいは同様のルーチンによって事前に作成された URI (Uniform Resource Identifier; 統一資源識別子) をデコードします。
試してみましょう
const uri = "https://mozilla.org/?x=шеллы";
const encoded = encodeURI(uri);
console.log(encoded);
// Expected output: "https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"
try {
console.log(decodeURI(encoded));
// Expected output: "https://mozilla.org/?x=шеллы"
} catch (e) {
// Catches a malformed URI
console.error(e);
}
構文
decodeURI(encodedURI)
引数
encodedURI
-
完全にエンコードされた URI。
返値
与えられたエンコードされた統一資源識別子 (URI) のエンコードされていないバージョンを表す新しい文字列。
例外
encodedURI
が無効な文字の並びを含む場合、URIError
("malformed URI sequence") 例外が発生します。
解説
エンコードされた URI のエスケープシーケンスを、それぞれが表す文字に置き換えます。ただし、encodeURI
によって生成されないエスケープシーケンスはデコードしません。また、"#
" の文字はエスケープシーケンスからデコードされません。
使用例
キリル文字の URL をデコード
js
decodeURI(
"https://developer.mozilla.org/ru/docs/JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B",
);
// "https://developer.mozilla.org/ru/docs/JavaScript_шеллы"
エラーの捕捉
try { var a = decodeURI('%E0%A4%A'); } catch(e) { console.error(e); } // URIError: malformed URI sequence
仕様書
Specification |
---|
ECMAScript® 2025 Language Specification # sec-decodeuri-encodeduri |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
decodeURI |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.