Javascript $(';#iframe';).load()在生产环境中响应非常晚,尽管它在开发(本地)环境中运行良好
警报(“已加载”)在生产后期触发。我想不出是什么原因导致它在生产后期启动 以下是原始代码的摘录:Javascript $(';#iframe';).load()在生产环境中响应非常晚,尽管它在开发(本地)环境中运行良好,javascript,jquery,iframe,Javascript,Jquery,Iframe,警报(“已加载”)在生产后期触发。我想不出是什么原因导致它在生产后期启动 以下是原始代码的摘录: <html> <head> <script> function showIframe () { var html = '<iframe id="myIframe" src="https://calendly.com/.../15min"></iframe>'; $("#testDiv
<html>
<head>
<script>
function showIframe () {
var html = '<iframe id="myIframe" src="https://calendly.com/.../15min"></iframe>';
$("#testDiv").html(html);
setTimeout(function () {
$("#myIframe").load(function (e){
alert('loaded');
});
}, 200);
}
</script>
</head>
<body>
<button onclick = 'showIframe()'>iFrame</button>
<div id = 'content' style = 'width: 100px; height: 100px; background-color: lemonchiffon;'></div>
</body>
</html>
函数showIframe(){
var html='';
$(“#testDiv”).html(html);
setTimeout(函数(){
$(“#myIframe”).load(函数(e){
警报(“已加载”);
});
}, 200);
}
iFrame
如果在IE/Edge下运行页面,加载https站点通常需要很长时间。谷歌你会找到关于它的链接。其他浏览器应该可以。我在此iframe中加载的URL是一个外部URL(即与我的网站无关)。