Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
How to check current page url in javascript?

I want to check if I am in certain domain, like this (in manifest.json for chrome extensions):

"content_scripts": [
{
  "matches": ["*://certain.site/*"],
  "js": ["some.js"]
}

But it seems like there are only dirty ways in javascript, like .split("/") which I don't want to use. Is there a clean way to do it?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can use the URL interface for that. Like:

const currentUrl = new URL(window.location.href);

Now you can get the things like path and hostname from the currentUrl, like currentUrl.pathname.

To get only the file name you now can do: currentUrl.pathname.split('/').pop()

about 4 years ago · Juan Pablo Isaza Report

0

you get detail of URL

console.log(location);

get current url

console.log(location.href);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!