Javascript 在具有动态内容的iframe中显示加载程序
我有一个iframe,它在引导模式中动态加载 我希望在模态体父div加载内容或单击时在内容之间切换时,仅在模态体父div内显示我的加载程序元素 我的代码: 来自小提琴的代码: HTML: 我怎样才能做到这一点呢?你的意思是Javascript 在具有动态内容的iframe中显示加载程序,javascript,jquery,html,iframe,twitter-bootstrap-3,Javascript,Jquery,Html,Iframe,Twitter Bootstrap 3,我有一个iframe,它在引导模式中动态加载 我希望在模态体父div加载内容或单击时在内容之间切换时,仅在模态体父div内显示我的加载程序元素 我的代码: 来自小提琴的代码: HTML: 我怎样才能做到这一点呢?你的意思是 $("#myModal iframe").on("load",function() { $("#loading").hide(); }); $('a.modalButton').on('click', function(e) { var src = $(th
$("#myModal iframe").on("load",function() {
$("#loading").hide();
});
$('a.modalButton').on('click', function(e) {
var src = $(this).attr('data-src');
var height = $(this).attr('data-height') || 300;
var width = $(this).attr('data-width') || 400;
$("#loading").show();
$("#myModal iframe").attr({'src':src,
'height': height,
'width': width})
});
请注意,只有当iFrame中的内容与脚本来自同一来源时,在iFrame中加载和导航时,onload处理程序才会起作用。
从iFrame内部,您可以尝试
$("a").on("click",function() {
parent.$("#loading").show();
});
你是说
$("#myModal iframe").on("load",function() {
$("#loading").hide();
});
$('a.modalButton').on('click', function(e) {
var src = $(this).attr('data-src');
var height = $(this).attr('data-height') || 300;
var width = $(this).attr('data-width') || 400;
$("#loading").show();
$("#myModal iframe").attr({'src':src,
'height': height,
'width': width})
});
请注意,只有当iFrame中的内容与脚本来自同一来源时,在iFrame中加载和导航时,onload处理程序才会起作用。
从iFrame内部,您可以尝试
$("a").on("click",function() {
parent.$("#loading").show();
});
找到了。这与找到它的iFrame无关。这与iFrame无关