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

274
Views
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 answers
Answer question

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 Report

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 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!