www.webdeveloper.com
Results 1 to 2 of 2

Thread: Message script - morning - afternoon - and night

  1. #1
    Join Date
    Dec 2005
    Posts
    1

    Smile Message script - morning - afternoon - and night

    I need a script thatcan shows pictures instead of the text messages good morning, good afternoon etc.

    Wil apreciate all help and tip.

    Have found this script with messages:
    <HEAD>

    <script type="text/javascript">
    <!--
    /* This script and many more are available free online at
    The JavaScript Source!! http://javascript.internet.com
    Created by: Robin Jones :: http://robinjones.freeuk.com */

    function greet() {
    var todaydate = new Date();
    var timeis = todaydate.getTime();
    todaydate.setTime(timeis);
    var houris = todaydate.getHours();
    if (houris > 17) display = "Evening";
    else if (houris >12) display = "Afternoon";
    else display = "Morning";
    var title = document.title;
    var welcome = ("Good " + display + ". Welcome to " + title +".");
    document.write(welcome);
    }
    -->
    </script>
    </HEAD>

    <!-- STEP TWO: Copy this code into the BODY of your HTML document -->

    <BODY>

    <script type="text/javascript">
    <!-- Begin
    greet();
    // End -->
    </script>

    <p><center>
    <font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
    by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
    </center><p>

    <!-- Script Size: 1.15 KB -->

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Code:
    <script type="text/javascript">
    hour = new Date ().getHours () 
    
    if (hour > 17) {
    	src = 'morning.png'
    	alt = 'Morning'
    } else if (hour > 12) {
    	src = 'afternoon.png'
    	alt = 'Afternoon'
    } else {	
    	src = 'morning.png'
    	alt = 'Morning'
    }
    
    document.write ('<img alt="', alt, '" src="', src, '">')
    </script>
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

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