Random Image in Dreamweaver?

I’m new to dreamweaver and I am looking to have a different image image load each time the page loads or reloads. Anyone know how to do this in Dream Weaver. Thanks

As far as I know this isnt possible without php, there may be a extension to do it in javascript but I very much doubt it.

Ill have a scout around!


there is a way to do with javascript. the most convenient way would be for you to go to the Macromedia Dreamweaver Exchange and download the random extra.

also look in your commands menu to see if a random image command is there. if not, go to the exchange and get.


This works with javascript and quite well however it requires two things that aren’t always turned on.

Javascript + cookies.

The dw extension mentioned isn’t one I have used but I do assume it uses this basic setup and then stores the last viewed picture within the cookie. It then reads that cookie and loads a different image. You could also do this entirely randomized but then you could feasibly end up having the same picture appear everytime.

If the DW extension doesn’t work then a server sided language would work best :slight_smile:

Random image script right here:

<script language=“JavaScript”>

function randomImage() {
   pic = new Array();
      pic[0] = ‘path/to/image_01.jpg’;
      pic[1] = ‘path/to/image_02.jpg’;
      pic[2] = ‘path/to/image_03.jpg’;
   randomNum = Math.floor(Math.random()*pic.length);
   newImage = pic[randomNum];

// –>

print it to the page like so:

<script language=“JavaScript” type=“text/javascript”>

cool, thanks. much smaller and compact then many others i’ve seen!