0

基本的に、1 つのページにこれらの折りたたみ div がたくさんあり、折りたたみ div 内に iframe があります。(css を使用して、クリック可能な div をボタンのように見せました。)

問題は、基本的にページが読み込まれるたびに各 iframe 内のすべてのドメインが読み込まれるため、ページの読み込みに非常に長い時間がかかることです。

divがクリックされない限り、iframeの読み込みを遅らせたい。

現在、私のコードは次のとおりです。

Javascript

jQuery(document).ready(function() {
  jQuery(".cont").hide();
  jQuery(".title").click(function()
  {
    jQuery(this).next(".cont").slideToggle(500);
  });
});

HTML

<div class="layer1">
<p class="title">test</p>
    <div class="cont">
        <iframe src="http://example.com" scrolling="no"></iframe>
    </div>
    <div class="cont">
        <iframe src="http://example2.com" scrolling="no"></iframe>
    </div>
    <div class="cont">
        <iframe src="http://example3etc.com" scrolling="no"></iframe>
    </div>

まだ解決策が必要です。

4

1 に答える 1

0

ボタンがクリックされた後にのみDOMに挿入するのはどうですか?

jQuery(document).ready(function() {
    $("cont1").click(function()
         {
            $("cont1").html("<iframe src='http://example1.com' scrolling="no"></iframe>")
          }
    );

    $("cont2").click(function()
         {
            $("cont2").html("<iframe src='http://example2.com' scrolling="no"></iframe>")
         }
     );

});

等々。そして、後で「削除」ボタンを使用してhtmlを削除できますか?

于 2013-08-05T01:17:58.257 に答える