Request Dev Services ยป

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 = "";
var current = window.location.href;

  if(current == homepage) {
     setTimeout(function () {
     window.location.href = "";
  }, 2000);

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

Leave a Reply

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