Results 1 to 1 of 1

Thread: Randomize images on refresh

  1. #1
    Join Date
    Sep 2009
    Thanked 0 Times in 0 Posts

    Default Randomize images on refresh

    I want to have 8 image adverts on my web page that change on refresh.

    Each one will have bring up a different image when the page is refreshed and it will also have a link to another page.

    I have copied part of the script below into a div so that i can place it where i want it on the page, and it works fine (so it changes on refresh and links to another page). But when i try to do a second div next to it with the same script but different image and links it does nothing.

    Can anyone tell me how to make make it work more than once.

    Thanks in advance

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

    <html xmlns="">
    <meta name="generator" content="BBEdit 7.0.3">
    <title>Home page - Company name</title>

    <!-- Hide script from old browsers

    var adImages=new Array()
    adImages[0] = "images/4541.jpg"
    adImages[1] = "images/47310B-040211-P1.JPG"
    adImages[2] = "images/32662.jpg"
    adImages[3] = "images/326100-030501-p1.JPG"

    var adURL=new Array()
    adURL[0] = "4541.html"
    adURL[1] = "47310.html"
    adURL[2] = "32662.html"
    adURL[3] = "326100.html"

    var adText=new Array()
    adText [0] = "Appraisal, risk management and remedial measures for major rock slopes."
    adText [1] = "Design of Remedial meaures to an unstable rail embankment."
    adText [2] = "Specialist advice regarding reclamation of a site contaminated by former colliery workings and processing."
    adText [3] = "Geotechnical and geoenvironmental advice for proposed city centre development located over two mainline railway tunnels at relatively shallow depth."

    thisAd = 0
    imgCt = adImages.length
    i = 0

    function choosePic(targetId) {
    if (document.getElementById) {
    target = document.getElementById(targetId);
    randomNum = Math.floor((Math.random() * imgCt));
    target.innerHTML = ("<A HREF='" + adURL[randomNum] + "'><IMG SRC='" + adImages[randomNum] + "' WIDTH='139' HEIGHT='110' NAME='featureBanner' ALT='Ad Banner'><\/a>" + "<span class='adtext'><font face='Gill sans, Helvetica, Verdana, Arial' size='1'>" + adText[randomNum] + "<\/font><\/span>")

    function newLocation() {
    parent.internalFrame.document.location.href = " " + adURL[randomNum]

    // End hiding script from old browsers -->

    <!--<style type="text/css" media="screen">
    @import url(edgeuk1.css);

    <LINK rel="STYLESHEET" type="text/css" href="edgeuk1.css">
    <body onLoad="choosePic('banner')">

    <div id="bannerTitle">
    <h1>Images from our Photograph Library</h1>
    <div id="banner">


    Last edited by stmal; 09-28-2009 at 01:42 PM.


Posting Permissions

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