Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

urlencode javascript

var url = encodeURIComponent('url');
Comment

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"
Comment

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

js encode url

encodeURIComponent('')
Comment

PREVIOUS NEXT
Code Example
Javascript :: remove a special character from string javascript 
Javascript :: react native navigation transparent header 
Javascript :: how to disable ctrl key using javascript 
Javascript :: add 1 day to date js 
Javascript :: javascript detect internet explorer 
Javascript :: javascript check if element has class 
Javascript :: document on click jquery 
Javascript :: ready function jquery 
Javascript :: javascript leave page warning 
Javascript :: npm create-react-app 
Javascript :: jquery script tag source google 
Javascript :: jquery submit form on enter 
Javascript :: Root composer.json requires tymon/jwt-auth ^0.5.12 - satisfiable by tymon/jwt-auth[0.5.12]. 
Javascript :: javascript get weekday name 
Javascript :: auto scroll to bottom of page js 
Javascript :: javascript even mouseout 
Javascript :: sort array by date moment 
Javascript :: javascript detect touch screen 
Javascript :: urlencode jquery 
Javascript :: kill all npm processes 
Javascript :: how to pad string js 
Javascript :: axios Cross origin http://localhost forbidden 
Javascript :: jquery body class add 
Javascript :: npm remove dev dependencies from node_modules 
Javascript :: remove element by class 
Javascript :: react fetch post 
Javascript :: slider is not a function jquery 
Javascript :: local storage javascript array 
Javascript :: angular rebuild 
Javascript :: track window resize in vue 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =