Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reload a page with parameters?

Tags:

jquery

I want to reload a page with some parameters I uses this code-

 location.reload('https://makemyfoam.com/checkout#three');

but it reload the page on https://makemyfoam.com/checkout.

I use javascript code-

 window.location.href = window.location.href + "#three";

it only adds the #three in URL instead of loading the page.

but I want to reload the page on https://makemyfoam.com/checkout#three .

like image 533
Vikas Verma Avatar asked Jan 27 '26 17:01

Vikas Verma


1 Answers

You can try

const loc = window.location;
loc.href = loc.origin + loc.pathname + "#three";
loc.reload()

PS: please note using location.origin+location.pathname+'#anchor' instead of location.href+'#anchor' to avoid getting something like that: https://www.example.com/page#anchor1#anchor2#anchor3

like image 152
Denis O. Avatar answered Jan 30 '26 06:01

Denis O.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!