[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1804
  • Last Modified:

jquery check if iframe is visible

Hello Experts,

Parent:
<IFRAME id="login" SRC="login.html"></IFRAME>

When I initially load this screen, I hide the iframe using
$('#login').hide();

I currently have code in login.html that adjusts the height of the iframe:
$(function() {
$('#login',window.top.document).height(170);
});

However, when this code is called, the iframe that was hidden in the parent becomes visible.
How do I execute this code so that it is only executed if the iframe is visible?

Thanks
0
jagku
Asked:
jagku
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
Maybe using : http://api.jquery.com/visible-selector/

$('#login:visible',window.top.document).height(170);

Open in new window

0
 
jagkuAuthor Commented:
Hi,
I think I have really confused myself this time!
For some reason this isn't kicking in properly.

I have drafted 3 files (attached) to illustrate the problem:

parent.html CALLS login.html CALLS test.html

The problem is that although I try and hide the test.html iframe in login.html
- the piece of code that changes the height of the iframe 'login' listed in parent.html still kicks in (even though the test.html iframe is invisible.  I don't want it to execute.

Can you see what am I missing?

Many Thanks (as usual!)
parent.html
login.html
test.html
0
 
jagkuAuthor Commented:
Although it doesn't answer my question (which wasn't clear in the first place) - it helps.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now