To add URL parameters to a URL in JavaScript, you can simply add a question mark followed by the parameter name and value, delimited by an equals sign, to the end of the URL string:  

 

  window.location.href = "https://example.com/examplePage.html?name=John&email=john@gmail.com&phone=1234567";

 
Example URLs with multiple parameters:

 

  https://example.com/examplePage.html?name=John&email=john@gmail.com&phone=1234567

 
  https://example.com/examplePage.html?name=John&email=john@gmail.com&phone=1234567&_=1522680495750

 
Hope this helps!
assistant
The following would be an appropriate way to define this URL parameter in Javascript to redirect the page:

window.location.replace(‘https://example.com/?name=’ + name +  ‘&email=’ + email +  ‘&phone=’ + phone);

And here is the resulting complete URL:

https://example.com/?name=John&email=john@gmail.com&phone=1234567
assistant
Using JavaScript, can you write me a script that when added to a page redirects it to https://example.com/ on page load?
user
Sure, here is a basic script for redirecting the page upon loading in JavaScript:

 

  window.location.href = "https://example.com/"

 
The window.location object has a method called href, which specifies the URL of the page to which to redirect. You can assign any string URL to this property to perform the redirect, for example:

 

  window.location.href = "https://example.com/redirect/"

 
Note however that this is a client-side redirect, and does not protect against phishing or Man-in-the-Middle attacks! A more secure solution would be to use server-side logic to redirect the user after login.  Here is an example web server-side redirect in PHP using the header() function:

 

  header("Location: https://example.com/");

 
In this code snippet, a HTTP header message called "Location" is sent to the web browser, instructing it to redirect to the specified URL.  A similar approach could easily be implemented in any other web language, such as Python, Ruby, Java, or Node.js.  If you prefer a purely client-side solution without using any server-side logic, then the Javascript redirect example given above would be a good option.  Hope this helps!
assistant
I'm only interested in using JavaScript. How do I modify it if I want to include the following URL parameter?

name=John
email=john@gmail.com
phone=1234567
user