How to get pathname from URL in JavaScript

1 Answer

0 votes
const url = "https://www.seek4info.com/search.php?type=sites&order=rand&query=wordpress+hosting";
 
const urlobj = new URL(url);
 
console.log(urlobj.pathname );

 
 
 
/*
run:
 
/search.php
 
*/

 



answered May 23, 2021 by avibootz

Related questions

2 answers 348 views
1 answer 275 views
1 answer 235 views
1 answer 283 views
1 answer 170 views
1 answer 243 views
243 views asked Jan 26, 2022 by avibootz
...