Skip to content

Latest commit

 

History

History
65 lines (53 loc) · 1.69 KB

File metadata and controls

65 lines (53 loc) · 1.69 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
encodeURI Function (JavaScript) | Microsoft Docs
01/18/2017
windows-client-threshold
devlang-javascript
language-reference
encodeURI
JavaScript
TypeScript
DHTML
encodeURI method
17bab5a2-bcd4-46c2-8b52-b2b5a0ed98a3
12
mikejo5000
mikejo
ghogen

encodeURI Function (JavaScript)

Encodes a text string as a valid Uniform Resource Identifier (URI)

Syntax

  
encodeURI(  
URIString  
)  
  

Remarks

The required URIString argument is a value representing an encoded URI.

The encodeURI function returns an encoded URI. If you pass the result to decodeURI, the original string is returned. The encodeURI function does not encode the following characters: ":", "/", ";", and "?". Use encodeURIComponent to encode these characters.

Example

The following code first encodes and then decodes a URI.

var uriEncode = encodeURI ("http://www.Not a URL.com");  
var uriDecode = decodeURIComponent(uriEncode);  
  
document.write(uriEncode);  
document.write("<br/>");  
document.write(uriDecode);  
  
// Output:  
// http://www.Not%20a%20URL.com  
// http://www.Not a URL.com  

Requirements

[!INCLUDEjsv55]

See Also

decodeURI Function
decodeURIComponent Function