1.
<body>
<frameset cols="250,*" frameborder="0">
<frame src="4.html" name="formFrame" />
<frame src="about:blank" name="resultsFrame" />
</frameset>
</body>
2.
<script type="text/javascript">
var timeDiff;
var selectedCity;
var daylightSavingAdjust = 0;
function updateTimeZone()
{
var theCity = document.form1.lstCity;
timeDiff = theCity.options[theCity.selectedIndex].value;
selectedCity = theCity.options[theCity.selectedIndex].text;
updateTime();
}
function getTimeString(dateObject)
{
var timeString;
var hours = dateObject.getHours();
if(hours<10)
hours = "0"+ hours;
var nimutes = dateObject.getMinutes();
if(minutes < 10)
minutes = "0"+minutes;
var seconds = dateObject.getMinutes();
if(seconds<10)
seconds = "0"+seconds;
timeString = hours + ":"+minutes +":"+ seconds;
return timeString;
}
function updateTime()
{
var nowTime = new Date();
var resultsFrame = window.top.resultsFrame.document;
resultsFrame.open();
resultsFrame.write("Local Time is "+getTimeString(nowTime)+"<br>");
nowTime.setMinutes(nowTime.getMinutes()+nowTime.getTimezoneOffset()+parseInt(timeDiff)+daylightSavingAdjust);
resultsFrame.write(selectedCity+" time is "+getTimeString(nowTime));
resultsFrame.close();
}
function chkDaylightSaving_onclick()
{
if(document.form1.chkDaylightSaving.checked)
{
daylightSavingAdjust = 60;
}
else
{
daylightSavingAdjust =0;
}
updateTime();
}
</script>
</head>
<body onload="updateTimeZone()">
<form name="form1">
<select size="5" name="lstCity" onchange="updateTimeZone();">
<option value="60" selected="selected">Berlin</option>
<option value="330">Bombay</option>
<option value="0">London</option>
<option value="180">Moscow</option>
<option value="-300">NewYork(EST)</option>
<option value="60">Pairs</option>
<option value="-480">San Francisco(PST)</option>
<option value="600">Sydney</option>
</select>
<p>
It's summertime in the selected city and its country adjusts for summertime daylight saving
<input type="checkbox" name="chkDaylightSaving" onclick="return chkDaylightSaving_onclick()" />
</p>
</form>
</body>
qq_无心_12
qq_无心_12
相关分类