Answers for "url encoded to string js"

4

js parse url encode

var set1 = ";,/?:@&=+$#"; // Caracteres reservados
var set2 = "-_.!~*'()";   // Marcas não reservadas
var set3 = "ABC abc 123"; // Caracteres alfanuméricos + Espaço

console.log(encodeURI(set1)); // ;,/?:@&=+$#
console.log(encodeURI(set2)); // -_.!~*'()
console.log(encodeURI(set3)); // ABC%20abc%20123 (o espaço é codificado como %20)
Posted by: Guest on December-29-2021
0

Encode URL in JavaScript?

Check out the built-in function encodeURIComponent(str) and encodeURI(str).
In your case, this should work:

var myOtherUrl = 
       "http://example.com/index.html?url=" + encodeURIComponent(myUrl);
Posted by: Guest on March-15-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language