New Message for each visit

  • Thread starter George W. Barrowcliff
  • Start date
G

George W. Barrowcliff

Does anyone have a sample of javascript which would recognize repeated
visits of a client to a web site and change a message each time the client
returns? Maybe cycle through 8-10 messages?

TIA
 
T

Trevor L.

George said:
Does anyone have a sample of javascript which would recognize repeated
visits of a client to a web site and change a message each time the
client returns? Maybe cycle through 8-10 messages?

TIA

Do you mean that you want to identify each client, and change the message
when that particular client returns?
Or that every time anyone visits the site, they get a different message?

The latter is reasonably easy to achieve, using a random number. It won't
guarantee a different message at the next visit, but with 10 messages, the
chances of getting the same message is 1 in 10.
--
Cheers,
Trevor Lawrence
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
----------------------------------------
 
G

George W. Barrowcliff

Thanks Trevor, I would like to change it each time the same user visits.
This site does not change very often and I wanted to give the illusion that
it was being kept up by making something different appear each time the user
returns.

GWB

Trevor L. said:
George said:
Does anyone have a sample of javascript which would recognize repeated
visits of a client to a web site and change a message each time the
client returns? Maybe cycle through 8-10 messages?

TIA

Do you mean that you want to identify each client, and change the message
when that particular client returns?
Or that every time anyone visits the site, they get a different message?

The latter is reasonably easy to achieve, using a random number. It won't
guarantee a different message at the next visit, but with 10 messages, the
chances of getting the same message is 1 in 10.
--
Cheers,
Trevor Lawrence
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
 
T

Trevor L.

George said:
Thanks Trevor, I would like to change it each time the same user
visits. This site does not change very often and I wanted to give the
illusion that it was being kept up by making something different
appear each time the user returns.

GWB

George,

I thought you might mean this, but it means retrieving the IP of the
visitor, and using that to determine what to display. This would mean using
server-side code, which comlicates things. In any case the IP can vary for
the same visitor if they are using a router which generates an IP
dynamically.

Here is an easy way to display a random image on each load (no matter who
the visitor is). Maybe this would achieve the same purpose.

The names of the images needs altering. It could be altered to display
random text fairly easily.
<html>
<head>
<script type="text/javascript">
var image_list = new Array(
"images/1.jpg",
"images/2.jpg",
"images/3.jpg",
"images/4.jpg",
"images/5.jpg",
"images/6.jpg")
function imgload()
{document.images('imgno').src = image_list[Math.ceil(Math.random() *
image_list.length) - 1]}
</script>
</head>
<body onload="imgload()">
<img id= "imgno" src="">
</body>
</html>
--
Cheers,
Trevor Lawrence
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
----------------------------------------
 
Top