Request Dev Services ยป

theDevTip.com

if URL is only at base URL then redirect (JS snips)

A quick code snippet which will check for absolute URL if there is no suffix (ie. #page or /page.htm etc); this is specifically used or useful when checking for a homepage or base URL.

var homepage = "http://www.website.com/";
var current = window.location.href;

  if(current == homepage) {
     setTimeout(function () {
     window.location.href = "http://www.website.com/navi/";
  }, 2000);
}

About the Author
Cameron Cashwell Web Developer
I build websites, web apps, and software. Wanna work together? Let's chat about your project!

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
admin Recent comment authors
  Subscribe  
newest oldest most voted
Notify of