This function will also work in that scenario. IFrame src can have redirects and therefore load a page different from the original src url. So, in any scenario, the callback function will run after iFrame is fully loaded. The load event is equivalent to readyState = "complete" which has been used to check whether iFrame is already loaded. So it uses the load event for running the callback function if iFrame isn't already loaded. Therefore, besides checking for readyState value, this function also addresses the about:blank issue.ĭOMContentLoaded event doesn't work with iFrame. So, the initial value of readyState will not represent the readyState of your actual iFrame. Later, it will replace `about:blank with the actual iframe src value. This also addresses the following issues:Ĭhrome initializes every iFrame with an about:blank page which will have readyState = "complete". This function will run your callback function immediately if the iFrame is already loaded or wait until the iFrame is completely loaded. Then, in the parent window you attach a handler to react to that event. To see what happens when the src domain is different from The iframe fires an event on the (potentially existing) parent window's document - please beware that the parent document needs a jQuery instance of itself for this to work. Use the preceeding link to change the src of the iframe ![]() To further the example, try using this as the content of the iframe: Child When I ran this code the URL '' did not have any restrictions and no loading errors. As if it's not allowed to be loaded the onload event will never be called. HTML tags: ,
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |