Post published over one year ago
Generally we use ‘path’ in web or in file system, to aim a target where we want to navigate.
The format, sometimes is confusing, when we are using changeable
For example, when this jekyll blog runs in local, the
localhost, while it is
In other cases, the situation might be more complex. For example, in dev env, the
base_url is example.com, while in prod env, it become example.com/welcome!
When we handle this, the final method is
location.href='example.html' //with history
location.replace('example.html') //without history
Of course, we can also use other ‘location’ to navigate from different source:
self.location.href;//Current page window.location.href;//Current page this.location.href;//Current page location.href;// Current page parent.location.href;//Parent page top.location.href;//Top page
However, how can we manage the format of path?
Click to download this playground html file :