Example 1: js window location relative path
//To fetch just the relative path of a window location. const RELATIVE_PATH = window.location.pathname;
Example 2: js redirect to relative url
window.location.href = '/product/api/mobile'; //relative to domain
window.location.href = "http://www.pakainfo.com/php.html";
Example 4: change windlow location relitave to current one
//Only line of Js code: window.location.href = '../'; //one-single level up
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.