(Msg. 1) Posted: Mon Nov 17, 2008 11:17 am
Post subject: Random Picture Selections Archived from groups: microsoft>public>frontpage>programming (more info?)
Running Front Page 2000 (V 4.0.2.2717)
(I know, but it works for my applications)
Here is the question:
I have several pictures that I would like to have come up one at a time
randomly on one of my sites.
They only have to come up different each time someone clicks on that certain
page. They do not have to change while that person is on that page. (If I can
have that happen too that would be fine)
So fare I am having no luck figuring out how to do this or where to go to
find out how to do this.
(Msg. 2) Posted: Tue Nov 18, 2008 3:00 am
Post subject: Re: Random Picture Selections [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
"Davet102" <Davet102.TakeThisOut@discussions.microsoft.com> wrote in message
news:A14E8D1B-8277-431F-9FF1-245364741B4A@microsoft.com...
> Running Front Page 2000 (V 4.0.2.2717)
> (I know, but it works for my applications)
>
> Here is the question:
>
> I have several pictures that I would like to have come up one at a time
> randomly on one of my sites.
>
> They only have to come up different each time someone clicks on that
> certain
> page. They do not have to change while that person is on that page. (If I
> can
> have that happen too that would be fine)
>
> So fare I am having no luck figuring out how to do this or where to go to
> find out how to do this.
>
> That is why I am here.
>
> Help please!!
>
Bob,
The code below selects a new image every time the page loads and when the
button is clicked. Sometimes the image does not change but that is because
the same number can be selected randomly
It would also be possible to set a rotation that changes every x seconds if
you want it
html>
<head>
<script type="text/javascript">
// Set up the image files to be used.
var theImages = new Array( // do not change this
/****************************************************
* To add more image files, continue with the *
* pattern below, adding to the array, *
* with a bracket after the last. *
****************************************************/
'images/1.jpg' ,
'images/2.jpg' ,
'images/3.jpg' ,
'images/4.jpg' )
// do not edit anything below this line
for (var preBuffer = new Array(), i = 0, p = theImages.length; i < p ; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
function showImage() {
document.images['myImage'].src=
theImages[Math.round(Math.random()*(p-1))];
}
</script>
</head>
<body onload="showImage();">
<p>
<button id="button1" onclick="showImage();">
Click to change image</button>
</p>
<img id="myImage" src=" ">
</body>
</html>
All times are: Eastern Time (US & Canada) (change)
Page 1 of 1
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum