Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Beginner
Mar 25, 2016

Using JavaScript to Redirect to a New Page

When a person comes to a page, it is actually possible to redirect them to a new page. Because someone might have bookmarked the page, you can use this when you want to remove a page from your site so that you can avoid sending the person to a 404 error page.

window.location = "http://www.devx.com"; 

This page will be gone in a blink of the eye because of the script redirect!

Looking at the code, you'll see that the window location is changed to www.devx.com. You could change this to any other site as well. The one downfall with this redirect is that if scripting is turned off, it won't work.

Brad Jones
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date