Detect when an iframe is displayed


vtloc

Currently, my website is being embedded in another website. But the problem is I want to know when my iframe is displayed so I can execute some script.

Similar to the following:

<div id="wrapper">
  <iframe id="page1">
       <!-- MY PAGE 1 CODE GOES HERE-->
  </iframe>
  <iframe id="page2">
       <!-- MY PAGE 2 CODE GOES HERE-->
  </iframe>
  <iframe id="page3">
       <!-- MY PAGE 3 CODE GOES HERE-->
  </iframe>
</div>

The problem here is that the wrapper loads all my embed codes at the same time, then hides them all and shows only one. Then, when the user interacts, it will display another page.

My problem is: I need to know when the wrapper shows my code for page 1/2/3 so that further processing can be done.

Hope to get some hints.

@edited 2014-02-15: The owner of the package is using my code. You can think of it as their plugin content.

The wrapper uses display:none to hide or show the iframe that wraps my content.

Ironwood

The answer depends on how to make the iframe invisible. A simple way to detect iframe visibility in an iframe, if display: noneused, is:

var isVisible = !!window.frameElement.offsetWidth; // --> true or false

offsetWidthEquals when set to in an iframe or one of its parent elements .0displaynone

Related


Detect when an iframe is displayed

vtloc Currently, my website is being embedded in another website. But the problem is I want to know when my iframe is displayed so I can execute some script. Similar to the following: <div id="wrapper"> <iframe id="page1"> <!-- MY PAGE 1 CODE GOES HER

Detect when an iframe is displayed

vtloc Currently, my website is being embedded in another website. But the problem is I want to know when my iframe is displayed so I can execute some script. Similar to the following: <div id="wrapper"> <iframe id="page1"> <!-- MY PAGE 1 CODE GOES HER

Detect when a view is (re)displayed

Weibo As the title suggests, how can I detect when the user sees a UIViewController. This is slightly different from viewDidLoad()and viewDidAppear(), both of which only run when the application is first launched. What I'm looking for is something similar view

How to detect when an iFrame is fullscreen?

near-point I have a document embedded in my website using iFrames. iFrame is from Box.com Document Viewer. iFrames have their own built-in fullscreen button. The fullscreen button is in an iFrame, so I can't attach a click event listener to the button. I added

Detect when Unicode characters cannot be displayed correctly

Jordan H Some unicode characters do not display on iOS, but display correctly on macOS. Likewise, some Unicode characters that iOS can display cannot be displayed on watchOS. This is due to the different built-in fonts installed on these platforms. If the char

Detect when TextBox autocomplete list is displayed

VBobCat I have TextBoxcontrols and associated timers that restart on every event KeyDownor MouseClickevent and execute a query based on the typed text after 3 seconds without these events. So far so good. But some of my textboxes also have an "autocomplete" li

Detect when Unicode characters cannot be displayed correctly

Jordan H Some unicode characters do not display on iOS, but display correctly on macOS. Likewise, some Unicode characters that iOS can display cannot be displayed on watchOS. This is due to the different built-in fonts installed on these platforms. If the char

Detect when TextBox autocomplete list is displayed

VBobCat I have TextBoxcontrols and associated timers that restart on every event KeyDownor MouseClickevent and execute a query based on the typed text after 3 seconds without these events. So far so good. But some of my textboxes also have an "autocomplete" li

Detect when TextBox autocomplete list is displayed

VBobCat I have TextBoxcontrols and associated timers that restart on every event KeyDownor MouseClickevent and execute a query based on the typed text after 3 seconds without these events. So far so good. But some of my textboxes also have an "autocomplete" li

How to detect when a jQuery Mobile popup is displayed

Aaron When the jQuery Mobile popup is shown, I need to listen to i am <a id="linkFoo" data-rel="popup" href='#fb-login-page'>loading<div data-role="popup" id="fb-login-popup"> When using data-role='page'an internal page that defines jQuery Mobile, I can listen

How to detect when a jQuery Mobile popup is displayed

Aaron When the jQuery Mobile popup is shown, I need to listen to i am <a id="linkFoo" data-rel="popup" href='#fb-login-page'>loading<div data-role="popup" id="fb-login-popup"> When using data-role='page'an internal page that defines jQuery Mobile, I can listen

Is there a way to detect when a cell is displayed on the screen?

shadow shadow I'm using TableViewand the media player GridView. Since loading music for all users at once doesn't work well when loading a lot of music, I'd like to lazy load as much as possible. One thing I do is to delay the loading of music files until they

Detect when Unicode characters cannot be displayed correctly

Jordan H Some unicode characters do not display on iOS, but display correctly on macOS. Likewise, some Unicode characters that iOS can display cannot be displayed on watchOS. This is due to the different built-in fonts installed on these platforms. If the char

Detect when TextBox autocomplete list is displayed

VBobCat I have TextBoxcontrols and associated timers that restart on every event KeyDownor MouseClickevent and execute a query based on the typed text after 3 seconds without these events. So far so good. But some of my textboxes also have "autocomplete" lists

Detect when TextBox autocomplete list is displayed

VBobCat I have TextBoxcontrols and associated timers that restart on every event KeyDownor MouseClickevent and execute a query based on the typed text after 3 seconds without these events. So far so good. But some of my textboxes also have an "autocomplete" li

How to detect when a jQuery Mobile popup is displayed

Aaron When the jQuery Mobile popup is shown, I need to listen to i am <a id="linkFoo" data-rel="popup" href='#fb-login-page'>loading<div data-role="popup" id="fb-login-popup"> When using data-role='page'an internal page that defines jQuery Mobile, I can listen

Detect when an iframe starts loading a new url

Philip: How can I detect that an iframe on a page starts loading a new page? Our situation is: When the iFrame content starts changing, we need to show the "loading" animation and hide the search box. I know how to handle the "iframe has finished loading" even

Detect when iframe content is loaded (cross browser)

David Snabel-Caunt : I'm trying to detect when an iframe and its contents have been loaded, with no luck. My app takes some input in the parent window's text field and updates the iframe to give a "live preview" I started with the following code (YUI) to detec

How to detect when an iframe has loaded

BT: $('#someIframe').load(function(){...})It doesn't seem to fire if the iframe is connected after it has finished loading . Is that right? What I really want is to have a function that is always called once when the iframe is loaded or after it is loaded. To

Detect when iframe content is loaded (cross browser)

David Snabel-Caunt : I'm trying to detect when an iframe and its contents have been loaded, with no luck. My app takes some input in the parent window's text field and updates the iframe to give a "live preview" I started with the following code (YUI) to detec

Detect when an iframe starts loading a new url

Philip: How can I detect that an iframe on a page starts loading a new page? Our situation is: When the iFrame content starts changing, we need to show the "loading" animation and hide the search box. I know how to handle the "iframe has finished loading" even

Detect loading of iframe in Chrome when downloading file

Merlin I am using a hidden iframe in an HTML page for download. I would like to know when it will be done. I've searched a lot on the internet and everyone says I should use the iframe's onloadevent handler, but it doesn't work in Chrome! I'm not sure where, b

Detect when iframe content is loaded (cross browser)

David Snabel-Caunt : I'm trying to detect when an iframe and its contents have been loaded, with no luck. My app takes some input in the parent window's text field and updates the iframe to give a "live preview" I started with the following code (YUI) to detec

How to detect when an iframe has loaded

BT: $('#someIframe').load(function(){...})It doesn't seem to fire if the iframe is connected after it has finished loading . Is that right? What I really want is to have a function that is always called once when the iframe is loaded or after it is loaded. To

Detect when an iframe starts loading a new url

Philip: How can I detect that an iframe on a page starts loading a new page? Our situation is: When the iFrame content starts changing, we need to show the "loading" animation and hide the search box. I know how to handle the "iframe has finished loading" even

Detect loading of iframe in Chrome when downloading file

Merlin I am using a hidden iframe in an HTML page for download. I would like to know when it will be done. I've searched a lot on the internet and everyone says I should use the iframe's onloadevent handler, but it doesn't work in Chrome! I'm not sure where, b