Cross-Domain IFRAME Loading Callback
You need to execute a callback when an IFRAME has finished loading, without direct access to the IFRAME content.
Solution with Timeout
As mentioned in the provided response, accessing the IFRAME body is possible if the URL is on the same domain. To address the issue of the callback not having data, try using a timeout to remove the IFRAME:
<code class="javascript">$('#myUniqueID').load(function () { if (typeof callback == 'function') { callback($('body', this.contentWindow.document).html()); } setTimeout(function () {$('#frameId').remove();}, 50); });</code>
This approach delays the removal of the IFRAME, allowing the callback to retrieve data before the element is destroyed.
The above is the detailed content of How to Execute a Callback When an IFRAME Finishes Loading Across Domains Without Direct Content Access?. For more information, please follow other related articles on the PHP Chinese website!