ChrisCapps
06-25-2002, 10:58 AM
Hi,
How can I modify this script so that the local time shows on my home page at load, with no button- or link-clicking necessary? In other words, I want my local time to write automatically on my home page at load, but I don't want it in a separate alert box/window.
I tried changing "alert" in the function to "document.write" and calling the function in the body, and it does write, but ON A TOTALLY SEPARATE PAGE from my home page. If I keep the "alert" as-is, and call the function in the body, the time writes in an alert window. Again, not what I want. Any ideas?
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- 540 from 9*60 because I'm in South Korea, which is GMT+8 and DST -->
<!-- Begin
function showlocaltime() {
var today = new Date();
var difftime = (today.getTimezoneOffset()+540) *60000;
today.setTime(today.getTime()+difftime);
alert(today.toLocaleString());
}
// End -->
</script>
</head>
<body>
<div align="center">
Click <a href="javascript:showlocaltime()">[here]</a> to find the current local time.
</div>
How can I modify this script so that the local time shows on my home page at load, with no button- or link-clicking necessary? In other words, I want my local time to write automatically on my home page at load, but I don't want it in a separate alert box/window.
I tried changing "alert" in the function to "document.write" and calling the function in the body, and it does write, but ON A TOTALLY SEPARATE PAGE from my home page. If I keep the "alert" as-is, and call the function in the body, the time writes in an alert window. Again, not what I want. Any ideas?
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- 540 from 9*60 because I'm in South Korea, which is GMT+8 and DST -->
<!-- Begin
function showlocaltime() {
var today = new Date();
var difftime = (today.getTimezoneOffset()+540) *60000;
today.setTime(today.getTime()+difftime);
alert(today.toLocaleString());
}
// End -->
</script>
</head>
<body>
<div align="center">
Click <a href="javascript:showlocaltime()">[here]</a> to find the current local time.
</div>