Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

277
Vistas
Use of $(parent.window).height()

I have a page which will sometimes be loaded in an iframe and sometimes just loaded by itself, depending on certain parameters which are not relevant for the purpose of this question. In both cases I want to get the height of the viewport so am using $(parent.window).height(). This seems to return the correct figure in both cases (in and out of an iframe), but I just wanted to check if there is any potential pitfall using $(parent.window).height() in a page which is not in an iframe - i.e. the page technically has no parent.

Otherwise I can structure an if..else with $(parent.window).height() and $(window).height() for in and out of an iframe respectively, but is is necessary? Can I just use $(parent.window).height() to cover both cases?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

The docs say that

If a window does not have a parent, its parent property is a reference to itself.

So you're good, window.parent will be a reference to the parent, if one exist, if not, it's a reference to the current window.
There's no need for a condition to check if the window actually has a parent to use the window.parent property, as long as it doesn't matter that it could be the current window that is returned.

over 4 years ago · Santiago Trujillo Denunciar

0

You can use window.top to refer to the topmost window. Whether a page is opened normally, or in a frame, or in a nested frame, it will always refer to the top window.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda