// Encode a URI:
var uri = "my test.asp?name=ståle&car=saab";
NSB.Print(encodeURI(uri));
(2 intermediate revisions by 2 users not shown) | |||
Line 11: | Line 11: | ||
The decodeURI() function is used to decode a URI. | The decodeURI() function is used to decode a URI. | ||
== Example | == Example == | ||
Encode a URI: | <tabber> | ||
< | JavaScript= | ||
<syntaxhighlight lang="JavaScript"> | |||
// Encode a URI: | |||
var uri = "my test.asp?name=ståle&car=saab"; | |||
NSB.Print(encodeURI(uri)); | |||
</syntaxhighlight> | |||
|-| | |||
BASIC= | |||
<syntaxhighlight lang="vb.net"> | |||
' Encode a URI: | |||
uri = "my test.asp?name=ståle&car=saab" | uri = "my test.asp?name=ståle&car=saab" | ||
Print encodeURI(uri) | Print encodeURI(uri) | ||
</pre> | </pre> | ||
</syntaxhighlight> | |||
< | </tabber> | ||
</ | |||
The result will be: | |||
The result | |||
<pre> | <pre> | ||
my%20test.asp?name=st%C3%A5le&car=saab | my%20test.asp?name=st%C3%A5le&car=saab |
encodeURI(URI)
decodeURI(URI)
The encodeURI() function is used to encode a URI.
This function encodes special characters, except: , / ? : @ & = + $ # (Use encodeURIComponent() to encode these characters).
The decodeURI() function is used to decode a URI.
// Encode a URI:
var uri = "my test.asp?name=ståle&car=saab";
NSB.Print(encodeURI(uri));
' Encode a URI:
uri = "my test.asp?name=ståle&car=saab"
Print encodeURI(uri)
</pre>
The result will be:
my%20test.asp?name=st%C3%A5le&car=saab