javascript redirect to relative url with parameters

Today, We want to share with you javascript redirect to relative url.In this post we will show you javascript redirect to url, hear for javascript redirect to url with parameters we will give you demo and example for implement.In this post, we will learn about JavaScript Redirect URL Example with an example.

javascript redirect to relative url with parameters

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

Example 3: javascript redirect to relative url

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 hope you get an idea about javascript redirect on page load.
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.