“JS codieren URL” Code-Antworten

Urlencode JavaScript

var url = encodeURIComponent('url');
QP2

JS Urlencode

/* There are 11 characters which are not encoded by encodeURI, 
but encoded by encodeURIComponent. */

encodeURI("test uri"); 
// "test%20uri"
encodeURI("test uri"); 
// "test%20uri"

encodeURI("test uri/with a slash"); 
// "test%20uri/with%20a%20slash"
encodeURIComponent("test uri/with a slash"); 
// "test%20uri%2Fwith%20a%20slash"
Frasween

JS Escape -URL -Parameter

var myUrl = "http://www.image.com/?username=unknown&password=unknown";
var encodedURL= "http://www.foobar.com/foo?imageurl=" + encodeURIComponent(myUrl);
GutoTrosla

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)
GutoTrosla

URL in JavaScript codieren?

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);
shafeeque

JS codieren URL

encodeURIComponent('')
Code Cat

Ähnliche Antworten wie “JS codieren URL”

Fragen ähnlich wie “JS codieren URL”

Weitere verwandte Antworten zu “JS codieren URL” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen