Jquery 如何将iframe的显示样式从无更改为块:
如何在用户单击jquery accordion div中的h3选项卡时强制执行iframe显示。由于某些原因,我的real surce链接被隐藏而不显示。对于这些虚拟链接,amazon、health和其他正在显示,但在我的真实链接中,它们是隐藏的?如果您仅在显示Iframe面板时才尝试加载Iframe,请尝试此操作 HTML 注意,我在custom属性中设置了iframe src,以防止在页面加载时加载它Jquery 如何将iframe的显示样式从无更改为块:,jquery,iframe,accordion,show-hide,Jquery,Iframe,Accordion,Show Hide,如何在用户单击jquery accordion div中的h3选项卡时强制执行iframe显示。由于某些原因,我的real surce链接被隐藏而不显示。对于这些虚拟链接,amazon、health和其他正在显示,但在我的真实链接中,它们是隐藏的?如果您仅在显示Iframe面板时才尝试加载Iframe,请尝试此操作 HTML 注意,我在custom属性中设置了iframe src,以防止在页面加载时加载它 <!DOCTYPE HTML> <html> <he
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" language="javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" language="javascript">
$(function() {
$( "#accordion" ).accordion({
collapsible: true,
heightStyle: "content",
animate: {
duration: 200,
down: {
easing: "easeOutBounce",
duration: 1000
}
}
});
});
</script>
</head>
<body>
<div id="accordion" style="width: 240px; height: 400px;">
<h3>Rig Counts</h3>
<div style="width: 238px; height: 270px;">
<iframe name="I1" id="I1" src="https://amazon.com" frameborder="0" width="100%" height="100%" scrolling="no">
</iframe>
</div>
<h3>Lost Time</h3>
<div style="width: 238px; height: 270px;">
<iframe name="I2" id="I2" src="http://ebay.com" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>
</div>
<h3>Rate Of Penetration</h3>
<div style="width: 238px; height: 270px;">
<iframe name="I3" id="I3" src="https://yahoo.com" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>
</div>
<h3>No Of Incident</h3>
<div style="width: 238px; height: 270px;">
<iframe name="I4" id="I4" src="https://google.com" frameborder="0" width="100%" height="100%" scrolling="no">
</iframe>
</div>
</div>
</body>
</html>
JS
请告诉我需要你的帮助。有什么帮助吗?我们需要您的帮助。所以您只想在iframe的面板显示时加载iframe的内容?它在这里工作,您使用的浏览器是什么?你修改了吗?你检查过JSFIDLE吗?你是对的,它在JSFIDLE中工作得很好,但我不知道为什么不在我的页面中工作。实际上,在我的手风琴中有一个来源的多个图表,但只有活动选项卡起作用。我不知道为什么。我认为问题的出现是因为iframe隐藏在jquery中,但似乎不是这样。还有一件事,当我删除脚本时,所有图表都会一个接一个地显示在我的网页上。我所做的是,我添加了一个脚本,可以在用户单击任何选项卡时刷新iframe,这对我来说很好,但我需要的是为这个问题找到一个永久性的解决方案。@Khalil我需要一个该问题的演示来提供帮助
<div id="accordion" style="width: 240px; height: 400px;">
<h3>Rig Counts</h3>
<div style="width: 238px; height: 270px;">
<iframe name="I1" id="I1" data-src="http://placehold.it/200&text=1" frameborder="0" width="100%" height="100%" scrolling="no">
</iframe>
</div>
<h3>Lost Time</h3>
<div style="width: 238px; height: 270px;">
<iframe name="I2" id="I2" data-src="http://placehold.it/200&text=2" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>
</div>
<h3>Rate Of Penetration</h3>
<div style="width: 238px; height: 270px;">
<iframe name="I3" id="I3" data-src="http://placehold.it/200&text=3" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>
</div>
</div>
<script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" language="javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" language="javascript">
function showIframe(panel){
$('iframe', panel).each(function(){
var iframe = $(this);
if( iframe.attr('src')==undefined ) iframe.attr('src', iframe.data('src') );
});
};
$(function() {
// show first
showIframe( $('#accordion div').eq(0) );
$( "#accordion" ).accordion({
collapsible: true,
heightStyle: "content",
animate: {
duration: 200,
down: {
easing: "easeOutBounce",
duration: 1000
}
},
beforeActivate: function( event, ui ) {
// show iframes before panel to be activated
showIframe(ui.newPanel);
}
});
});
</script>