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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • timothyd
    New Member
    • Feb 2008
    • 2

    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.
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Originally posted by timothyd
    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="documen t.getElementByI d('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.

    Comment

    • drhowarddrfine
      Recognized Expert Expert
      • Sep 2006
      • 7434

      #3
      html/css cannot do this but javascript and server side languages can. I'll move this there.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        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

        Comment

        • hsriat
          Recognized Expert Top Contributor
          • Jan 2008
          • 1653

          #5
          Originally posted by acoder
          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.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by hsriat
            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.

            Comment

            • hsriat
              Recognized Expert Top Contributor
              • Jan 2008
              • 1653

              #7
              Originally posted by acoder
              Hmm, non-English stuff... I wonder who's been guilty of that.
              Oh! So you remember!! Good Memory!!

              Comment

              • timothyd
                New Member
                • Feb 2008
                • 2

                #8
                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.

                Comment

                • hsriat
                  Recognized Expert Top Contributor
                  • Jan 2008
                  • 1653

                  #9
                  Originally posted by timothyd
                  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

                  Comment

                  Working...