473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Create area on web page that displays different photo each time website visited

Hello, I am a true beginner and have no clue what I am doing. With that said, I really only want to know one thing...how do I create and insert an area on the main page of my website that displays a different photo each time the website is visited/each time the refresh button is pushed? Please let me know. Thank you.
Feb 22 '08 #1
8 1794
hsriat
1,654 Expert 1GB
Hello, I am a true beginner and have no clue what I am doing. With that said, I really only want to know one thing...how do I create and insert an area on the main page of my website that displays a different photo each time the website is visited/each time the refresh button is pushed? Please let me know. Thank you.
There can be many solutions. But I'll tell you one of them.
  • Save all the pictures (you need to display once at a time) in a folder (say banners).
  • Save them all as 0.png, 1.png, 2.png.... and so on. (keep only one extension thing, jpg or gif or png.)
  • Amend the HTML like this.. [html]<body onload="document.getElementById('banner').src= '/banners/' + Math.round(Math.random()*99) + '.png'">
    <img id="banner" src=""></img>
    [/html]

PS: 99 is used if you have 100 images... multiply with one less than the actual number of images.
Feb 22 '08 #2
drhowarddrfine
7,435 Expert 4TB
html/css cannot do this but javascript and server side languages can. I'll move this there.
Feb 22 '08 #3
acoder
16,027 Expert Mod 8TB
Please remember to provide a meaningful Title for any threads started (see the FAQ entry Use a Good Thread Title).

This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

MODERATOR
Feb 22 '08 #4
hsriat
1,654 Expert 1GB
Please remember to provide a meaningful Title for any threads started (see the FAQ entry Use a Good Thread Title).

This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

MODERATOR
You have been given a good duty!!!! ....

:p .. just a joke. I saw you many times adding [code] tags and deleting non-English stuff from other's posts.
Feb 22 '08 #5
acoder
16,027 Expert Mod 8TB
You have been given a good duty!!!! ....

:p .. just a joke. I saw you many times adding [code] tags and deleting non-English stuff from other's posts.
Yes, moderation 'duties' - someone's gotta do it! Hmm, non-English stuff... I wonder who's been guilty of that.
Feb 22 '08 #6
hsriat
1,654 Expert 1GB
Hmm, non-English stuff... I wonder who's been guilty of that.
Oh! So you remember!! Good Memory!!
Feb 22 '08 #7
That didn't work. You just mean save the banners folder to my computer?
I have never used html before. I created my website with the simple iweb program that comes on macs. There is an option to insert an html snippet, and a box appears where the inserted html will show up, I dragged this box to the size of the pictures that I wanted, and inserted the html code (both 1 & 2) that you told me. But my website just has a blue box and a question mark.
Feb 22 '08 #8
hsriat
1,654 Expert 1GB
That didn't work. You just mean save the banners folder to my computer?
I have never used html before. I created my website with the simple iweb program that comes on macs. There is an option to insert an html snippet, and a box appears where the inserted html will show up, I dragged this box to the size of the pictures that I wanted, and inserted the html code (both 1 & 2) that you told me. But my website just has a blue box and a question mark.

Oh! So now I got your point!!
You want to be creative ha?
I don't know about this iweb program, but it may be helpful for you if you learn some basics of HTML. Then use the above code, it will work. HTML ain't difficult!

The banners folder needs to be in the same folder as the HTML file is. And since your HTML is created by iweb, it won't allow you to edit the <body> tag.

PS: I really liked your idea of each-time-new-banner on the website!!
I'm gonna use it on my website!! Thanks
Feb 22 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

179
by: SoloCDM | last post by:
How do I keep my entire web page at a fixed width? ********************************************************************* Signed, SoloCDM
3
by: CodeRazor | last post by:
Hi, I am trying to dynamically create linkbuttons. They need an event handler, so i can respond to the user's click. I try to add the eventhandler on the fly, but when i click on the link, the...
1
by: Anita C | last post by:
Hi, How cookies can be used to set and then determine the last page visited by a person browsing a particular website ? Also the page last visited is loaded in an iframe, so the page last visited...
6
by: rs | last post by:
I wonder, performance wise, if it is better to have one form and repaint the components on that form or to have mutiple forms and show and dispose them? Thanks
13
by: Viken Karaguesian | last post by:
Hello everyone, Can anyone recommend a good online site to learn PHP? The W3Schools website is quite lacking - leaves much to be desired. I'm sure there are many places, but which ones are good?...
8
by: RC | last post by:
I found background-color, background-image, but I don't see background-text. I would like have some text write to the padding areas like th, td { margin: 0; border-width: 1; width: 40px; height:...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
7
by: canajien | last post by:
How can I get a php page to automatically send all the contents in an email when it is generated? I managed to hack together a script that sends an email, but it will only send the 1st record...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.