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 352 views
1 answer 277 views
1 answer 242 views
1 answer 285 views
1 answer 173 views
1 answer 246 views
246 views asked Jan 26, 2022 by avibootz
...