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

134
Views
JavaScript get portion of a page URL

Is there a way using HTML css and JavaScript that I can find the URL of a webpage after the first 10 characters. For example, if the URL is random.com/abc the program would only get the /abc part of the URl and log it in the console. How can this be done?

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

0

You need to get the pathname from the window location object.

window.location.pathname
about 4 years ago · Juan Pablo Isaza Report

0

You can use window.location.href along with substring() to select a range of characters or characters after a particular index.

window.location.href.substring(10);
about 4 years ago · Juan Pablo Isaza Report

0

To get the path, use the pathName.

console.log(window.location.pathname);
console.log((new URL('http://www.example.com/abc/123')).pathname);

There is no reason to split and use indexes.

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!