Log in

View Full Version : greeting according to time



chechu
12-28-2007, 08:42 AM
Hey,
I saw on a site a greeting (good morning); that changes at noon into 'good day', and at two in 'good afternoon', etc.
Anyone has that script ?

codeexploiter
12-28-2007, 09:14 AM
You can use the following code



tme = new Date();
hrstme = tme.getHours();
var timemsg;

if (hrstme < 7){
timemsg = "Good morning, you are very early! "
}else if (hrstme > 6 && hrstme <12){
timemsg = "Good morning! "
}else if (hrstme > 11 && hrstme <18){
timemsg = "Good afternoon! "
}else if (hrstme >17 && hrstme < 23){
timemsg = "Good night! "
}
document.write(timemsg)}

chechu
12-28-2007, 09:34 AM
Now the tricky thing:
I'd like to place this in the hover text " Good--, welcome to the officia ..." on http://www.cecicasariego.com
(move over the flags).
How can this be done, please ?

codeexploiter
12-28-2007, 09:46 AM
In the normal case the title attribute of <a> will give you some tooltip kind of items as default in IE and FF (not sure about other browsers).

In your case there is a function (JS) being called while hovering the mouse over the flags. If you remove those functions the tooltip will be displayed. Or we need to check a more specific tooltip script (JS) that suits your purpose.

If you can remove the 'onmouseover' event from the below mentioned <a> tags then the tooltip will appear. If it is not possible then plz let me know about it. Following tags doesn't have a onmouseover as I've removed them to show that.


<a title="Welcome to officia..." href="http://www.cecicasariego.com/indexGB.html"><img src="Welcome%20to%20the%20official%20website%20of%20Ceci%20Casariego%20Mazereel_files/vlagEN.gif" style="border: 0pt none ;"></a>
<a href="http://www.cecicasariego.com/indexNL.html" title="Welcome to officia..."><img src="Welcome%20to%20the%20official%20website%20of%20Ceci%20Casariego%20Mazereel_files/vlagNL.gif" style="border: 0pt none ;"></a>

chechu
12-28-2007, 09:51 AM
If you can remove the 'onmouseover' event from the below mentioned <a> tags then the tooltip will appear.
I'd like to leave the onmouseover as it is now, but adding the greeting in the appearing text.

codeexploiter
12-28-2007, 09:53 AM
The following is a good tooltip application developed in JavaScript, which i think simple to customize for your purpose.

http://www.dustindiaz.com/sweet-titles/

sometimes you have to adjust the onmouseover event in a manner that it does your job as well as the tooltip show.

Edited

http://www.dynamicdrive.com/dynamicindex5/dhtmltooltip.htm - another one from DD