www.webdeveloper.com
Results 1 to 4 of 4

Thread: Randomize Image and Iframe

  1. #1
    Join Date
    Aug 2014
    Posts
    3

    Randomize Image and Iframe

    Hi I've been using this code to randomize my image adverts using the follwing code.

    Code:
    <script type="text/javascript">
    var total_images = 3;
    var random_number = Math.floor((Math.random()*total_images));
    var random_img = new Array();
    random_img[0] = '<a href=link0.html" ><img src="image0.jpg"/></a>';
    random_img[1] = '<a href=link1.html" ><img src="image1.jpg"/></a>';
    random_img[2] = '<a href=link2.html" ><img src="image2.jpg"/></a>';
    document.write(random_img[random_number]);
    </script>
    But I want to include multiple <iframe></<iframe> into the code
    I tried replacing the whole line with the iframe but it doesn't work.
    Can anybody help me with a solution?
    Thank you in advance

  2. #2
    use iframe above the total images.

  3. #3
    Join Date
    Aug 2014
    Posts
    3
    I want to randomize the iframe as well. Is that possible?

  4. #4
    Join Date
    Aug 2014
    Posts
    3
    like such

    Code:
    <script type="text/javascript">
    var total_images = 3;
    var random_number = Math.floor((Math.random()*total_images));
    var random_img = new Array();
    random_img[0] = '<a href=link0.html" ><img src="image0.jpg"/></a>';
    random_img[1] = '<a href=link1.html" ><img src="image1.jpg"/></a>';
    random_img[2] = '<a href=link2.html" ><img src="image2.jpg"/></a>';
    random_img[3] = '<iframe 1></<iframe>';
    random_img[4] = '<iframe 2></<iframe>';
    random_img[5] = '<iframe 3></<iframe>';
    document.write(random_img[random_number]);
    </script>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles