简体   繁体   English

仅在打开Bootstrap手风琴时加载iFrame

[英]Load iFrame in Bootstrap accordion only when opened

I am trying to have the iframes inside the bootstrap 3 accordion to load only when the item is opened. 我正在尝试使bootstrap 3手风琴内部的iframe仅在打开该项目时加载。 Right now all iframes load at the same time when page loads and it causes the page to load for a long time. 现在,所有iframe在页面加载时会同时加载,这会导致页面长时间加载。 How to stop the iframes loading until the accordion item is opened? 如何在打开手风琴项目之前停止iframe加载?

Here is my collapse code: 这是我的收合代码:

<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
    <div class="panel-heading" role="tab" id="heading1">
        <h4 class="panel-title">
            <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse1" aria-expanded="false" aria-controls="collapse1">
                Title 1 goes here
            </a>
        </h4>
    </div>
    <div id="collapse1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading1">
        <ul class="list-group">
            <li class="list-group-item"> <iframe src="http://www.google.com"></iframe> </li>
        </ul>
    </div>
</div>
<div class="panel panel-default">
    <div class="panel-heading" role="tab" id="heading2">
        <h4 class="panel-title">
            <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse2" aria-expanded="false" aria-controls="collapse2">
                Title 2 goes here
            </a>
        </h4>
    </div>
    <div id="collapse2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading2">
        <ul class="list-group">
            <li class="list-group-item"> <iframe src="http://www.yahoo.com"></iframe> </li>
        </ul>
    </div>
</div>

您可以将SRC属性保留为空白,然后挂钩/设置您自己的事件侦听器,以了解何时打开手风琴项目以设置iframe的SRC属性,然后

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM