- Content – you can use your old free domain to divert visitors to your new web site’s content. For example, I have a website called email@example.com, then I can redirect visitors to read more content on my new website .
- Redirect the visitor with user inputs.
- Redirect the visitor with a message.
We will see when user will click the button, it will be directed to the sharplesson’s website. To redirect, we have used a custom function, you can put any name instead of ‘SharpLessonRedirect ()’. When a reader will click the button, it will call the function SharpLessonRedirect (). The ‘window.location’ will open the web page URL ‘’.
Now we will see two output’s:
First output will be:
When the reader will click the above ‘ Come & Redirect’, then it will open the sharplesson’s website:
Second output will be:
Yes, finally your small code have redirected the page to a sharplesson website.
In this example we will show a message to our readers, and it will redirect the reader to the new location in a few seconds. We have used ‘SharpLessonRedirect ()’, and setTimeout () to set the time delay to 6 seconds.
When you will run this program, you will see two results:
The first result will be:
It will show the above result first, and then it will redirect to:
The second result will be:
Here, again you got the sharplesson.com as a redirected url.
Points to Remember
- We have used ‘SharpLessonRedirect ()’ function. You can have any name, like yours or pet as well.
- We have used setTimeout () with two arguments. The first argument is ‘SharpLessonRedirect ()’ which will come into action after the delay time. And the second argument is time in milliseconds, we have set 6000 seconds.