Iframe:修订间差异
来自康健生活
| 第15行: | 第15行: | ||
=== IE === | === IE === | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
iframe?.contentDocument?.addEventListener('readystatechange', iframeHandleListener, {passive: false}); | |||
</syntaxhighlight> | </syntaxhighlight> | ||
eq: | |||
<syntaxhighlight lang="javascript"> | |||
//check for IE | |||
if (navigator.userAgent.indexOf("MSIE") > -1 && !window.opera){ | |||
iframe.onreadystatechange = function(){ | |||
if (iframe.readyState == "complete"){ | |||
alert("Iframe is loaded."); | |||
} | |||
}; | |||
} else { | |||
iframe.onload = function(){ | |||
alert("Iframe is loaded."); | |||
}; | |||
}</syntaxhighlight> | |||
=== 非 IE === | === 非 IE === | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
iframeRef?.contentDocument?.addEventListener('load', iframeHandleListener, {passive: false}); | iframeRef?.contentDocument?.addEventListener('load', iframeHandleListener, {passive: false}); | ||
</syntaxhighlight> | </syntaxhighlight> | ||