SORU
12 EKİM 2009, PAZARTESİ


Nasıl bir iframe jquery kullanarak içeriği dinamik olarak değiştirebilirim?

Eğer bir iframe ile bir site ve iframe içeriğini her 30 saniyede bir değişiyor bazı jquery kodu var mümkün olup olmadığını merak ediyordum. İçeriği farklı web sayfalarında.

Şöyle bir şey:

<html>
  <head>
    <script type="text/javascript" src="jquery.js"></script>
    <script>
      $(document).ready(function(){
        var array = new array();
        array[0] = 'http://webPage1.com';
        array[1] = 'http://webPage2.com';
        // And so on.
        // Do something here to change the iframe every 30 second
      });
    </script>
  </head>
  <body>
    <iframe id="frame"></iframe>
  </body>
</html>

CEVAP
12 EKİM 2009, PAZARTESİ


<html>
  <head>
    <script type="text/javascript" src="jquery.js"></script>
    <script>
      $(document).ready(function(){
        var locations = ["http://webPage1.com", "http://webPage2.com"];
        var len = locations.length;
        var iframe = $('#frame');
        var i = 0;
        setInterval(function () {
            iframe.attr('src', locations[  i % len]);
        }, 30000);
      });
    </script>
  </head>
  <body>
    <iframe id="frame"></iframe>
  </body>
</html>

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • cdgotx

    cdgotx

    8 Kasım 2011
  • KendrickLamarVEVO

    KendrickLama

    9 ŞUBAT 2011
  • Numberphile

    Numberphile

    15 EYLÜL 2011