Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
Get the domain and page name from a String URL

Well i'm currently have some issue about manipulating an URL.

Technically what i want is to get the domain name and the page name from a page.

For example :

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 Respostas
Responde à pergunta

0

window.location.hostname; //Domain name

$("title").text(); //Page name

EDIT:

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 Relatório

0

try with url.match(/:\/\/(.[^/]+)/)[1]

example :

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 Relatório

0

Use window.location.hostname or window.location.host. Check location reference.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda