确定何时加载了IFrame的内容 [英] Determining when contents of an IFrame has loaded
问题描述
注意:我不相信这是检测的副本无法加载iframe的内容或检测iframe内容的时间已加载(跨浏览器)(或任何类似的)。
NB: I don't believe this is a duplicate of Detect failure to load contents of an iframe or Detecting when Iframe content has loaded (Cross browser) (or any of the similar ones).
简而言之,我使用IFrame使用浏览器的内部显示Pdfs观众。由于我们只支持Chrome / FF(我们使用WebGL)并且都有嵌入式Pdf查看器,因此它是避免实现 pdf.js (至少在我们需要更多控制/可以节省资源之前)。
In short I'm using an IFrame to display Pdfs using the browsers' internal viewer. Since we only support Chrome/FF (we use WebGL) and both have an embedded Pdf viewer, it's a convenient way to avoid implementing pdf.js (at least until we need more control / can spare the resource).
这就是说,我们确实希望能够检测IFrame何时完成加载,以便我们可以正确转换/检测问题。
That said, we do want to be able to detect when the IFrame has finished loading so we can transition properly/detect problems.
因此,假设IFrame源是pdf(并且pdf来自同一个域名),有没有办法确定iframe何时从外部加载?
So, assuming the IFrame source is a pdf (and the pdf is coming from the same domain), is there any way to determine when the iframe has loaded from the outside ?
推荐答案
使用iframe的onload事件。简单
Use onload event of iframe.Simple
<iframe src="test.pdf" onload="alert('Worked')" ></iframe>
这篇关于确定何时加载了IFrame的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!