07-14-2012، 12:09 PM
س !!!!!!!!!!!!!!!!!!! چند کد ساعت !!!
این کد واسه نمایش ساعت بکار می ره که کاربر می تونه اونه به 12 ساعت یا 24 ساعت تغییر بده.
اینم یه کد دیگه واسه نمایش ساعت در دکمه.
اینم به کد دیگه واسه نمایش ساعت در تکست باکس.
سوالی نیست؟
این کد واسه نمایش ساعت بکار می ره که کاربر می تونه اونه به 12 ساعت یا 24 ساعت تغییر بده.
کد:
<!-- THREE STEPS TO INSTALL CLOCK TYPE:
1. Paste the first code in the HEAD of your HTML document
2. Copy the onLoad event handler into the BODY tag
3. Add the last code in the BODY of your HTML document -->
<!-- STEP ONE: Paste the first code in the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function showMilitaryTime() {
if (document.form.showMilitary[0].checked) {
return true;
}
return false;
}
function showTheHours(theHour) {
if (showMilitaryTime() || (theHour > 0 && theHour < 13)) {
if (theHour == "0") theHour = 12;
return (theHour);
}
if (theHour == 0) {
return (12);
}
return (theHour-12);
}
function showZeroFilled(inValue) {
if (inValue > 9) {
return "" + inValue;
}
return "0" + inValue;
}
function showAmPm() {
if (showMilitaryTime()) {
return ("");
}
if (now.getHours() < 12) {
return (" am");
}
return (" pm");
}
function showTheTime() {
now = new Date
document.form.showTime.value = showTheHours(now.getHours()) + ":" + showZeroFilled(now.getMinutes()) + ":" + showZeroFilled(now.getSeconds()) + showAmPm()
setTimeout("showTheTime()",1000)
}
// End -->
</script>
<BODY onLoad="showTheTime()">
<!-- STEP THREE: Add the last code in the BODY of your HTML document -->
<BODY>
<center><form name=form>
<input type=text name=showTime size=11><p>
<input type=radio name=showMilitary checked>Military Time<br>
<input type=radio name=showMilitary>12 Hour Time<br>
</form></center>
</table>
</form>
</FONT>
</CENTER>
</center>
</body></html>
اینم یه کد دیگه واسه نمایش ساعت در دکمه.
کد:
<!-- ONE STEP TO INSTALL BUTTON TIME:
1. Put the coding into the BODY of your HTML document -->
<!-- STEP ONE: Add this code into the BODY of your HTML document -->
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Michael Tartaglia <stonedstan@hotmail.com> -->
<!-- Web Site: http://www.geocities.com/SiliconValley/Horizon/5235 -->
<! >
<! >
<!-- Begin
day = new Date();
miVisit = day.getTime();
function clock() {
dayTwo = new Date();
hrNow = dayTwo.getHours();
mnNow = dayTwo.getMinutes();
scNow = dayTwo.getSeconds();
miNow = dayTwo.getTime();
if (hrNow == 0) {
hour = 12;
ap = " AM";
} else if(hrNow <= 11) {
ap = " AM";
hour = hrNow;
} else if(hrNow == 12) {
ap = " PM";
hour = 12;
} else if (hrNow >= 13) {
hour = (hrNow - 12);
ap = " PM";
}
if (hrNow >= 13) {
hour = hrNow - 12;
}
if (mnNow <= 9) {
min = "0" + mnNow;
}
else (min = mnNow)
if (scNow <= 9) {
secs = "0" + scNow;
} else {
secs = scNow;
}
time = hour + ":" + min + ":" + secs + ap;
document.form.button.value = time;
self.status = time;
setTimeout('clock()', 1000);
}
function timeInfo() {
milliSince = miNow;
milliNow = miNow - miVisit;
secsVisit = Math.round(milliNow / 1000);
minsVisit = Math.round((milliNow / 1000) / 60);
alert("There have been " + milliSince + " milliseconds since midnight, January 1, 1970. "
+ "You have spent " + milliNow + " of those milliseconds on this page. "
+ ".... About " + minsVisit + " minutes, and "
+ secsVisit + " seconds.");
}
document.write("<form name=\"form\">"
+ "<input type=button value=\"Click for info!\""
+ " name=button onClick=\"timeInfo()\"></form>");
onError = null;
clock();
// End -->
</SCRIPT>
<!-- Script Size: 1.72 KB -->
اینم به کد دیگه واسه نمایش ساعت در تکست باکس.
کد:
<!-- THREE STEPS TO INSTALL CURRENT TIME:
1. Paste the specified coding into the HEAD of your HTML document
2. Add the onLoad event handler to the BODY tag
2. Put the last code into the BODY of your HTML document -->
<!-- STEP ONE: Copy this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<! >
<! >
<!-- Begin
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
if (timeValue == "0") timeValue = 12;
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " P.M." : " A.M."
document.clock.face.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
function startclock() {
stopclock();
showtime();
}
// End -->
</SCRIPT>
<!-- STEP TWO: Add this onLoad event handler to the BODY tag -->
<BODY onLoad="startclock()">
<!-- STEP THREE: Copy this code into the BODY of your HTML document -->
<CENTER>
<FORM name="clock">
<input type="text" name="face" size=13 value="">
</FORM>
</CENTER>
<!-- Script Size: 1.45 KB -->
سوالی نیست؟
::::::::::::::::::::::::: دیگه میرم ... :::::::::::::::::::::::::