Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Picture on Each Access

Status
Not open for further replies.

dance

Technical User
Nov 6, 2002
142
US
I have seen a website that the picture in the header changes each time you access that page. How do they do that?
 
This is often done with a 3rd party random images script or rotating banner ad type script. It can be done with ASP or CGI - depending on what your server supports. Probably can be done with Javascript too - but I have only done this with ASP.

If you do a search on google for random images script or rotating banner ad, you should get a lot of good returns.

Tiffany

Microsoft MVP - FrontPage
 
Here's some JavaScript I use. It randomly selects from a list of several photos. Just insert it in your code where you want the picture to appear and edit the URL's for the images.

Code:
<script language="JavaScript">

/*
Random Image Link Script
By Website Abstraction ([URL unfurl="true"]http://www.wsabstract.com)[/URL]
and Java-scripts.net ([URL unfurl="true"]http://www.java-scripts.net)[/URL]
*/

function random_imglink(){
  var myimages=new Array()
  //specify random images below. You can have as many as you wish
  myimages[1]="images/bve1.gif"
  myimages[2]="images/bve2.gif"
  myimages[3]="images/bve3.gif"
  myimages[4]="images/bve4.gif"
  myimages[5]="images/bve5.gif"

  //specify corresponding links below
  var imagelinks=new Array()
  imagelinks[1]="[URL unfurl="true"]http://www2.bv.k12.oh.us"[/URL]
  imagelinks[2]="[URL unfurl="true"]http://www2.bv.k12.oh.us"[/URL]
  imagelinks[3]="[URL unfurl="true"]http://www2.bv.k12.oh.us"[/URL]
  imagelinks[4]="[URL unfurl="true"]http://www2.bv.k12.oh.us"[/URL]
  imagelinks[5]="[URL unfurl="true"]http://www2.bv.k12.oh.us"[/URL]

  var ry=Math.floor(Math.random()*myimages.length)

  if (ry==0)
     ry=1
     document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
}

  random_imglink()

</script>


::)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top