iframe 在点击事件时加载
Iframe loaded upon click event
我的页面中有多个 iframe,这大大降低了我的网页速度。
我该如何解决这个问题?
我的想法是onload每个iframe?
例如
$('iframe').each(function() {
$('iframe').onload();
});
任何帮助都会很棒。
编辑
我意识到我可以从下面的评论中点击事件加载 iframe src,所以我在下面修改了我的答案。
谢谢@Mike McCaughan 和@Obsidian Age - 我已经改编了你的参考资料并让它发挥作用。页面速度现在很棒!
从 iframe 中删除了 src=""
$(document).ready(function(){
$('a[data-reveal-id="corporate-profile"]').click(function() {document.getElementById("corporate-profile-iframe").src = "http://www.example.com/resources/corporate-profile/index.html";
...
...
(multiple accounts of iframes)
});
我的页面中有多个 iframe,这大大降低了我的网页速度。
我该如何解决这个问题?
我的想法是onload每个iframe? 例如
$('iframe').each(function() {
$('iframe').onload();
});
任何帮助都会很棒。
编辑
我意识到我可以从下面的评论中点击事件加载 iframe src,所以我在下面修改了我的答案。
谢谢@Mike McCaughan 和@Obsidian Age - 我已经改编了你的参考资料并让它发挥作用。页面速度现在很棒!
从 iframe 中删除了 src=""
$(document).ready(function(){
$('a[data-reveal-id="corporate-profile"]').click(function() {document.getElementById("corporate-profile-iframe").src = "http://www.example.com/resources/corporate-profile/index.html";
...
...
(multiple accounts of iframes)
});