Log in

View Full Version : Auto time close and other



hakopa
02-14-2006, 03:59 AM
Hello,
Please I am looking at a script that can set a html page to close at a certain time.
I also want the script to gather information from the OS.

EG. act as a more fancy batch script by useing commands like:
%USERNAME%
%time%
%date%

The problem is i dont know the html code.

What is the code for show a username:
eg. welcome <the user name script> (this is so it will display their username THEY LOGED ON AS)

The time is <time code>

Thanks for any help you can provide me with:

1) auto close script
2) time code
3) username code

THANKS AGAIN:confused:

Twey
02-14-2006, 10:50 AM
I also want the script to gather information from the OS.The server's OS or the client's OS?
If the former, you need to use a server-side technology such as PHP. If the latter:
The username cannot be gleaned from the OS. This is a security measure and can/should not be bypassed. The time:

<p id="time"></p>
<script type="text/javascript">
var timeToClose = "12:15" // 24-hour, no leading zeroes
onload = updateTime = function() {
var d = new Date();
document.getElementById("time").innerHTML = d.getHours() + ":" + d.getMinutes();
if(document.getElementById("time").innerHTML == timeToClose) window.close();
window.setTimeout("updateTime()", 1000);
}
</script>The paragraph can be any text element, but it must have an ID of "time". Auto-close code is in red above. Note that some browsers will ask for confirmation before closing the window.

jscheuer1
02-14-2006, 11:12 AM
Twey,

Did I miss something or where's this element? :

document.getElementById("time")

Twey
02-14-2006, 12:06 PM
Whoops, sorry, intended to point that out but forgot. Edited in.