Welcome to the staging ground for new communities! Each proposal has a description in the "Descriptions" category and a body of questions and answers in "Incubator Q&A". You can ask questions (and get answers, we hope!) right away, and start new proposals.
How do I implement a redirect in JavaScript Question
My web host only lets me upload static files. They don't support .htaccess
or dynamic scripting. As such, I can't implement 301 redirects between pages.
I should be able to put some JavaScript in a static HTML page to redirect the user to another page. How would I do that?
1 answer
There's a number of ways to send the user to another URL in JS (from [1]):
// Simulate a mouse click:
window.location.href = "http://www.w3schools.com";
// Simulate an HTTP redirect:
window.location.replace("http://www.w3schools.com");
However, this is pretty janky. I'd suggest reconsidering your host of choice, to avoid having to do such tricks :) For one, this is an abuse of HTTP because you are not issuing a 301.
0 comment threads