Is there a way to have Javascript autodetect wether its server is local(127.0.0.1) or production(http://www.example.com) and set a variable accordingly?

For example in PHP is use this function to do reloads and it works local or production:

```
  public static function reload()
    {
    $uri = 'http://';
    $uri .= $_SERVER['HTTP_HOST'];
    header('Location: '.$uri);
    }

```

This way I won't have to remember to edit my local\_on variable when uploading my script from development to production.