美女时钟
<!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>欢迎来到daomul的博客,欢迎再来,谢谢</title>
<script type="text/javascript">
//var now = new Date();不能放在这,否则取得时间不变
function Fill2Len(i) {
if (i < 10) {
return "0" + i;
}
else {
return i;
}
}
function Refresh() {
var imgMM = document.getElementById("imgMM");
if (!imgMM) {
return; //没加载就直接return
}
var now = new Date(); //每次刷新时取得时间
var filename = Fill2Len(now.getHours()) + "_" + Fill2Len(now.getSeconds()) + ".jpg";
imgMM.src = "MMClock/" + filename;
}
setInterval("Refresh()", 1000);
</script>
</head>
<body>
<img src="" />
</body>
</html>
案例6:搜索框关键字搜索
复制代码 代码如下:
搜索框关键字搜索
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>欢迎来到daomul的博客,欢迎再来,谢谢(文本框关键字3)</title>
<script type="text/javascript">
function inputBlur(keyword) {
if (keyword.value.length <= 0) {
keyword.value = "请输入搜索关键词";
keyword.style.color = 'Gray';
}
}
function inputFocus(keyword) {
//var keyword = document.getElementById("keyword");把this传给两个方法,省去了getElementById依赖id
if (keyword.value == "请输入搜索关键词") {
keyword.value = "";
keyword.style.color = 'Black';
}
}
</script>
</head>
<body>
<input onblur="inputBlur(this)" onfocus="inputFocus(this)" value="请输入搜索关键词" />
<input type="button" value="搜索" />
</body>
</html>
16、Form表单: Form 对象是表单的 Dom 对象。