Javascript if/else statement in iframe
Posted
by gr33nh4t
on Stack Overflow
See other posts from Stack Overflow
or by gr33nh4t
Published on 2010-06-16T22:48:41Z
Indexed on
2010/06/16
22:52 UTC
Read the original article
Hit count: 149
So I'm trying to use javascript to pop up a video, and need to know when I'm in an iframe so I can resize the video accordingly.
When outside the iframe, I see three alerts ('this is seen by both', 'not in iframe', and 'this is after the fact')
When in the iframe, I just see the first alert ('this is seen by both').
var handleViewVideoClick = function (dataAction, eventType, targetElement, dataActionElement) {
alert('this is seen by both');
if ($('iframe', window.parent.document).length == 0) {
alert('not in iframe');
} else {
alert('in iframe');
}
alert('this is after the fact...');
};
What's going on here?
© Stack Overflow or respective owner