Last active
August 29, 2015 13:56
-
-
Save Massay/1fdd1e6bc093c50e2f45 to your computer and use it in GitHub Desktop.
Simple Time function and ajax page caller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myobject; | |
try{ myobject=new ActiveObject("Microsoft.XMLHTTP"); } | |
catch(e) { try{ myobject=new ActiveObject("Msxml2.XMLHTTP"); } | |
catch(e) { myobject=false; } } | |
if(!myobject) { myobject=new XMLHttpRequest(); | |
} | |
function getPages(page,location) | |
{ var loca=document.getElementById(location); | |
myobject.open("GET",page); | |
myobject.onreadystatechange= function() | |
{ | |
if(myobject.readyState==4 && myobject.status==200) { | |
loca.innerHTML=myobject.responseText; | |
} | |
} myobject.send(); | |
} | |
function time() | |
{ var time=new Date(); /*var day=time.getDay(); var month=time.getMonth(); var year=time.getYear();*/ | |
var h=time.getHours(); var m=time.getMinutes(); var s=time.getSeconds(); var am_pm="AM"; | |
if(h>12) { h=h-12; am_pm="PM"; } | |
else if(h==0) { h=12; } | |
if(m<10) { m="0"+m; } | |
if(s<10) { s="0"+s; } | |
var position=document.getElementById("keep_time"); | |
position.innerHTML="Time is "+h+":"+m+":"+s+" "+am_pm; | |
setTimeout('time()',1000); } time(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment