Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

html redirect to another page

<script>
  function foo() {
  	window.location.href = url
  }
</script>
Comment

How do I redirect to another webpage

// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");

// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";

// Another method for doing redirecting with JavaScript is this:
window.location = "https://stackoverflow.com";
Comment

redirect to another webpage?

// similar behavior as an HTTP redirect
window.location.replace("http://codegrepper.com");

// similar behavior as clicking on a link
window.location.href = "http://codegrepper.com";

window.location.href; // Returns the href (URL) of the current page
window.location.hostname; // Returns the domain name of the web host
window.location.pathname; // Returns the path and filename of the current page
window.location.protocol; // Returns the web protocol used (http: or https:)
window.location.assign; // Loads a new document
window.location.replace; // RReplace the current location with new one.
Comment

PREVIOUS NEXT
Code Example
Javascript :: new line in p tag react 
Javascript :: MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string. 
Javascript :: post data from api using jquery ajax 
Javascript :: parse csv javascript 
Javascript :: local storage remove multiple items 
Javascript :: useScreens() react native 
Javascript :: jquery select all checkboxes 
Javascript :: dynamic style react 
Javascript :: javascript random numbers 
Javascript :: regex for exactly n digits 
Javascript :: using .includes for an array of objects js 
Javascript :: get object value in node js 
Javascript :: add event listener in react useeffect 
Javascript :: how to define state in react function 
Javascript :: get the first word of a string javascript 
Javascript :: mmap() failed: [12] Cannot allocate memory composer 
Javascript :: image upload in react js 
Javascript :: how to create a form without a submit button javascript 
Javascript :: set data-id javascript 
Javascript :: javascript array of zeros 
Javascript :: vuejs get the url params withour router 
Javascript :: how to reset input field in javascript 
Javascript :: vue.js slots 
Javascript :: square root javascript 
Javascript :: Reached heap limit Allocation failed - JavaScript heap out of memory nodejs 
Javascript :: regexp constructor js 
Javascript :: trim string after - in jquery 
Javascript :: ityped react 
Javascript :: express response setTimeout 
Javascript :: javascript sort by date descending 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =