boyhello456
05-05-2009, 19:00
em đang làm ví dụ về việc làm trễ một hành động mà sửa hoài mà nó vẫn không chạy đc. Mong các anh/ chị fix lỗi dùm em
<Quote>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Làm trễ một hành động</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="javascript">
var justWait;
function showAlert(theDelay){
alert('Đã trải qua ' + (theDelay/1000) + ' giây.');
}
function startAlert(){
var theDelay = document.forms[0].seconds.value * 1000;
justWait = setTimeOut ('showAlert(' + theDelay + ')', theDelay);
}
function stopAlert(){
clearTimeOut(justWait);
alert('Bộ định giờ đã được ngưng!');
}
</script>
</head>
<body>
<form id="EntryField" name="EntryField" action="none" >
<input class="inputField" type="text" name="seconds" id="theDelay" size="5" tabindex="0"><br>
<span class="instructions">Hướng dẫn</span>
<br>
<br>
<p>1. Nhập vào số giây muốn ngưng</p>
<p>2. Nhấp <a href="#" onClick="javascript : startAlert();"> vào đây </a> để bắt đầu gọi hàm</p>
<p>3. Nhấp <a href="#" onClick="javascript : stopAlert();"> vào đây </a> để ngưng gọi hàm</p>
</form>
</body>
</html>
</Quote>
<Quote>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Làm trễ một hành động</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="javascript">
var justWait;
function showAlert(theDelay){
alert('Đã trải qua ' + (theDelay/1000) + ' giây.');
}
function startAlert(){
var theDelay = document.forms[0].seconds.value * 1000;
justWait = setTimeOut ('showAlert(' + theDelay + ')', theDelay);
}
function stopAlert(){
clearTimeOut(justWait);
alert('Bộ định giờ đã được ngưng!');
}
</script>
</head>
<body>
<form id="EntryField" name="EntryField" action="none" >
<input class="inputField" type="text" name="seconds" id="theDelay" size="5" tabindex="0"><br>
<span class="instructions">Hướng dẫn</span>
<br>
<br>
<p>1. Nhập vào số giây muốn ngưng</p>
<p>2. Nhấp <a href="#" onClick="javascript : startAlert();"> vào đây </a> để bắt đầu gọi hàm</p>
<p>3. Nhấp <a href="#" onClick="javascript : stopAlert();"> vào đây </a> để ngưng gọi hàm</p>
</form>
</body>
</html>
</Quote>