Solved

jquery check if iframe is visible

Posted on 2011-03-01
3
1,720 Views
Last Modified: 2012-05-11
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
Comment
Question by:jagku
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35010133
Maybe using : http://api.jquery.com/visible-selector/

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

Open in new window

0
 

Author Comment

by:jagku
ID: 35012384
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
 

Author Closing Comment

by:jagku
ID: 35016444
Although it doesn't answer my question (which wasn't clear in the first place) - it helps.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
This article discusses how to implement server side field validation and display customized error messages to the client.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question