Deprecato
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
Sommario
La funzione escape()
, deprecata, crea una nuova stringa nella quale alcuni caratteri vengono sostituiti con una sequenza di escape esadecimale. È preferibile usare le funzioni encodeURI()
o encodeURIComponent()
.
Sintassi
escape(string)
Parametri
string
- La stringa da codificare.
Descrizione
La funzione escape()
è una proprietà dell'oggetto globale. Vengono codificati tutti i caratteri speciali, ad eccezione di: @ * _ + - . /
I caratteri vengono sostituiti con codici esadecimali che possono avere due caratteri, se il loro valore è minore o ugugale a 0xFF, (%xx) oppure quattro (%uxxxx).
Esempi
escape("abc123"); // "abc123"
escape("äöü"); // "%E4%F6%FC"
escape("ć"); // "%u0107"
// Caratteri speciali
escape("@*_+-./"); // "@*_+-./"
Specifiche
Specifica | Stato | Commenti |
---|---|---|
ECMAScript 1st Edition. | Standard | Definizione iniziale. |
ECMAScript 5.1 (ECMA-262) The definition of 'escape' in that specification. |
Standard | Definita nell'appendice B, "Compatibility" |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'escape' in that specification. |
Standard | Definita nell'appendice B, "Additional ECMAScript Features for Web Browsers" |
Compatibilità con i browser
Funzionalità | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Supporto di base | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Funzionalità | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Supporto di base | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |