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

107
Visualizações
Change window location href in subdomain iframe

I have a.example.com and b.example.com;

When I put b.example.com/foo as iframe in a.example.com:

<iframe src='b.example.com/foo'></iframe>`

the window.location.href value accessible from b.example.com is ... a.example.com/foo (??)...

The problem is - I use an external library in b.example.com/foo that checks for window.location.href and it gets incorrect information.

For this scenario it appears to me that I should iframe /foo content on a completely different domain like: anotherexample.com/foo, where the window.location.href would actually point to anotherexample.com/foo.

How can I force window object in iframe to actually use its subdomain instead of parent domain with added parameter?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Are you sure you are using your script in the right subdomain? it seems your external library is accessing parent window using window.parent.location, here is a code to check if a page is loaded directly or within another page:

var is_loaded_directly = (window.location == window.parent.location);

Since this code works, something is wrong on your setup or library.

Note: maybe you can solve your issue by checking document.location instead of window.location.

about 4 years ago · Juan Pablo Isaza 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