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

177
Views
Obtenga el dominio y el nombre de la página de una URL de cadena

Bueno, actualmente tengo un problema con la manipulación de una URL.

Técnicamente, lo que quiero es obtener el nombre de dominio y el nombre de la página de una página.

Por ejemplo :

 www.myWebSite.com => domain : myWebSite http://myWebSite.com => domain : myWebSite myWebSite.com/xxx.hmtl => domain : myWebSite page : xxx
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

window.location.hostname; //Domain name $("title").text(); //Page name

EDITAR:

 var loc = window.location; var filename = loc.pathname.split("/"); filename = filename[pathname.length-1]; alert("Domain: "+loc.hostname); alert("Filename: "+filename);
over 4 years ago · Santiago Trujillo Report

0

prueba con url.match(/:\/\/(.[^/]+)/)[1]

ejemplo :

 var r = /:\/\/(.[^/]+)/; "http://stackoverflow.com/questions/5343288/get-the-domain-and-page-name-from-a-string-url".match(r)[1] => stackoverflow.com
over 4 years ago · Santiago Trujillo Report

0

Utilice window.location.hostname o window.location.host . Verifique la referencia de ubicación .

over 4 years ago · Santiago Trujillo 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!