日期:2014-05-16 浏览次数:20478 次
<html>
<head>
<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{alert(alerttxt);
document.getElementById("test").value = "Changed!";
return false
}
else {return true}
}
}
function validate_form(thisform)
{
with (thisform)
{
if (validate_required(email,"Email must be filled out!")==false)
{email.focus();return false}
}
}
</script>
</head>
<body>
<form action="submitpage.htm" onSubmit="return validate_form(this)" method="post">
Email: <input type="text" name="email" size="30">
<input type="submit" value="Submit">
</form>
<p name = "test" >prepare to be changed</p>
</body>
</html>
document.getElementById("test").value = "Changed!";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
</head>
<body>
页面原来的内容<br />
页面原来的内容<br />
页面原来的内容<br />
页面原来的内容<br />
页面原来的内容<br />
页面原来的内容<br />
页面原来的内容<br />
页面原来的内容<br />
<script type="text/javascript">
function aaa()
{
document.write("<p>原来的内容全没了</p>");
alert(document.body.innerHTML);
}
setTimeout(aaa,10000);//10秒后网页应该已经加载完
</script>
</body>
</html>