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 247 views
1 answer 172 views
1 answer 156 views
1 answer 191 views
1 answer 103 views
1 answer 165 views
165 views asked Jan 26, 2022 by avibootz
...