vendredi 8 février 2019

How can I display a random image each time a particular web pages loads?

I have a particular page that is part of a website; it is coded directly in HTML. I have four images, and want to display a random one of them in a particular place on that page each time the page is loaded by anyone.

I have tried numerous examples; the one that seemed most logical to me was to have a function that would return a random integer from 1-4, and then I could simply put

so if the function happened to return a "2", the HTML that would execute would be giving me

I have found functions that are supposed to provide a random 0, 1, 2, or 3, but I can't get this approach to work. I am not a programming expert, although I am pretty good in straightforward HTML.




Aucun commentaire:

Enregistrer un commentaire