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);
More Related Contents:
- How to create query parameters in Javascript?
- How do I get the YouTube video ID from a URL?
- Get current URL with jQuery?
- Change the URL in the browser without loading the new page using JavaScript
- Adding a parameter to the URL with JavaScript
- Check if a JavaScript string is a URL
- How to convert URL parameters to a JavaScript object? [duplicate]
- URL hash-bang (#!/) prefix instead of simple hash (#/) in Angular 1.6
- Trying to Validate URL Using JavaScript
- How do I get the fragment identifier (value after hash #) from a URL?
- JavaScript URL Decode function
- Pass vars to JavaScript via the SRC attribute
- How do I parse a URL query parameters, in Javascript? [duplicate]
- How can I get a specific parameter from location.search? [duplicate]
- Getting an absolute URL from a relative one. (IE6 issue)
- SecurityError: The operation is insecure – window.history.pushState()
- How to extract base URL from a string in JavaScript?
- Javascript Image Url Verify
- Sending user to their browser’s Home Page using Javascript
- How to detect URL changes with jQuery
- How can I match on, but exclude a regex pattern?
- How to test if a URL string is absolute or relative?
- REGEX: Capture Filename from URL without file extension
- Is there any way to download csv file from “website button click” using Python?
- get url after “#” in express.js middleware request
- Make a JavaScript array from URL
- Why is “javascript:” pseudo-protocol stripped from URL bar when pasted?
- jQuery add class based on page URL
- Extract keyword from Google search in Javascript
- How could I change window’s location without reloading and # hack?