Javascript if/else statement in iframe
- by gr33nh4t
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?