#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    Arrow Onload random div content?


    Hello.

    I was hoping someone could help me with a little system that makes sure the following happens (I haven't done anything in Javascript yet, but desperately need this content ASAP, I'm on a dead-line):

    Every time a visitor loads a page, say, the homepage, I need for it to play either:

    <embed src="../flash/banner1.swf"></embed>
    or
    <embed src="../flash/banner2.swf"></embed>.

    ... in the same div, for example, to make it easier.
    This must be random. How can I possibly achieve this?

    Thanks in advance!
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,118
    Rep Power
    119
    Code:
    <div>
    <embed id="banner"></embed>
    </div>
    
    <script>
    var banners = new Array("../flash/banner1.swf","../flash/banner2.swf");
    (function(){
    document.getElementById("banner").src = banners[Math.round(Math.random()*(banners.length-1))];
    })();
    </script>

IMN logo majestic logo threadwatch logo seochat tools logo