www.webdeveloper.com
Results 1 to 7 of 7

Thread: time greeting: images instead of text

  1. #1
    Join Date
    May 2011
    Posts
    4

    time greeting: images instead of text

    hello,

    found that script and it works great but it would be more than nice if i could have images instead of the "good", "morning", "afternoon" and "evening" text..

    may someone here could help me out?
    thanks in advance.

    cheers, andi

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Could be something like this:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script type="text/javascript">
    onload=function(){
    var images=['morning.gif','afternoon.gif','evening.gif']; // the relative url of the images
    var today=new Date();
    var HH=today.getHours();
    var div=document.getElementById('greetings');
    var imgURL=HH>18?images[2]:HH>12?images[1]:images[0];
    var img=document.createElement('img');
    img.alt=imgURL.split('.')[0];
    img.src=imgURL;
    div.appendChild(img);
    }
    </script>
    </head>
    <body>
    <div id="greetings"></div>
    </body>
    </html>

  3. #3
    Join Date
    May 2011
    Posts
    4
    hello,

    thanks for your reply.
    i would test it but if it's possible, i would like to use the script linked in my first post as it's already in use and it works great..

    so, any other hints in here?
    thanks in advance.

    cheers, andi

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by andi*h View Post
    i would like to use the script linked in my first post as it's already in use and it works great..i
    Then use it.

    Now, seriously, you must understand that that code inserts text. That is all. You can not use that code, because it does not do what you need. Is it so hard to understand? If you want something else, then you should modify the code, right? I have modified that code. Fell free to use my changes.
    Last edited by Kor; 05-05-2011 at 08:32 AM.

  5. #5
    Join Date
    May 2011
    Posts
    4
    but there is text and no images...
    isn't it possible to "simply" change that?

    cheers, andi

  6. #6
    Join Date
    May 2011
    Posts
    4
    i do...but not really. as i easily can change any text within a html file to any image, i thought it's maybe possible to modify that script just a little bit.

    if not, i think i'll try it with your script, thanks.

    cheers, andi

  7. #7
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by andi*h View Post
    but there is text and no images...
    isn't it possible to "simply" change that?
    But I have changed that. To insert the img elements you must create them and append them. I really don't understand what you want. You wanted a code which displays different images according to the part of the day. I have written a code which does what you want, A simple code, I would dare to say. If you want something else, please tell me exactly what else do you want.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles