javascript 实例(-)
来源:互联网 发布:猛龙数据 编辑:程序博客网 时间:2024/06/05 06:31
1 创建一个运行于无穷循环中的计时器,我们需要编写一个函数来调用其自身。在下面的例子中,当Start count按钮被点击后,输入域便从 0 开始计数。当Stop count按钮被点击时,停止计数
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
var c=0
var t
function timedCount()
{
document.getElementById('txt').value=c
c=c+1
t=setTimeout("timedCount()",1000)
}
function stopCount()
{
clearTimeout(t)
}
</script>
</head>
<body>
<form>
<input type="button" value="Start count!" onClick="timedCount()">
<input type="text" id="txt">
<input type="button" value="Stop count!" onClick="stopCount()">
</form>
</body>
</html>
2 利用map area创建地图热点 不同位置鼠标划过会有不同的提示内容
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
function writeText(txt)
{
document.getElementById("desc").innerHTML=txt
}
</script>
</head>
<body>
<img src="1.jpg" width="145" height="126" alt="Planets" usemap="#planetmap" />
<map id ="planetmap" name="planetmap">
<area shape ="rect" coords ="0,0,40,40"
onMouseOver="writeText('The Sun and the gas giant planets like Jupiter are by far the largest objects in our Solar System.')"
href ="sun.htm" target ="_blank" alt="Sun" />
<area shape ="circle" coords ="60,58,6"
onMouseOver="writeText('The planet Mercury is very difficult to study from the Earth because it is always so close to the Sun.')"
href ="mercur.htm" target ="_blank" alt="Mercury" />
<area shape ="circle" coords ="80,70,8"
onMouseOver="writeText('Until the 1960s, Venus was often considered a twin sister to the Earth because Venus is the nearest planet to us, and because the two planets seem to share many characteristics.')"
href ="venus.htm" target ="_blank" alt="Venus" />
</map>
<p id="desc"></p>
</body>
</html>
3 鼠标划过和移除时显示不同图片
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
function writeText(txt)
{
document.getElementById("desc").innerHTML=txt
}
</script>
</head>
<body>
<img src="1.jpg" width="145" height="126" alt="Planets" usemap="#planetmap" />
<map id ="planetmap" name="planetmap">
<area shape ="rect" coords ="0,0,40,40"
onMouseOver="writeText('The Sun and the gas giant planets like Jupiter are by far the largest objects in our Solar System.')"
href ="sun.htm" target ="_blank" alt="Sun" />
<area shape ="circle" coords ="60,58,6"
onMouseOver="writeText('The planet Mercury is very difficult to study from the Earth because it is always so close to the Sun.')"
href ="mercur.htm" target ="_blank" alt="Mercury" />
<area shape ="circle" coords ="80,70,8"
onMouseOver="writeText('Until the 1960s, Venus was often considered a twin sister to the Earth because Venus is the nearest planet to us, and because the two planets seem to share many characteristics.')"
href ="venus.htm" target ="_blank" alt="Venus" />
</map>
<p id="desc"></p>
</body>
</html>
4 html标签 focus 和blur 函数调用方法
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
function writeText(txt)
{
document.getElementById("desc").innerHTML=txt
}
</script>
</head>
<body>
<img src="1.jpg" width="145" height="126" alt="Planets" usemap="#planetmap" />
<map id ="planetmap" name="planetmap">
<area shape ="rect" coords ="0,0,40,40"
onMouseOver="writeText('The Sun and the gas giant planets like Jupiter are by far the largest objects in our Solar System.')"
href ="sun.htm" target ="_blank" alt="Sun" />
<area shape ="circle" coords ="60,58,6"
onMouseOver="writeText('The planet Mercury is very difficult to study from the Earth because it is always so close to the Sun.')"
href ="mercur.htm" target ="_blank" alt="Mercury" />
<area shape ="circle" coords ="80,70,8"
onMouseOver="writeText('Until the 1960s, Venus was often considered a twin sister to the Earth because Venus is the nearest planet to us, and because the two planets seem to share many characteristics.')"
href ="venus.htm" target ="_blank" alt="Venus" />
</map>
<p id="desc"></p>
</body>
</html>
- javascript 实例(-)
- javascript实例(二)
- JAVASCRIPT二维数组(实例)
- JavaScript 正则表达式(实例)
- JavaScript实例
- JavaScript 实例
- javascript实例
- javaScript实例
- JavaScript基础之继承(附实例)
- JavaScript简介及入门实例(转载)
- 了解JavaScript中的prototype (实例)
- JavaScript-实例(实现展开效果)
- JavaScript String(字符串)对象 实例
- javaScript"闭包" - (实例理解)
- JavaScript Date(日期)对象 实例
- JavaScript基础知识及实例(二)
- JavaScript常用知识及其实例(三)
- JavaScript常用知识及其实例(四)
- 在dropdownlist上添加默认项
- Oracle编写存储过程
- 在js查看json的代码
- String类常用方法之charAt()、codePointAt()示例
- WordPress:Akismet in BlogEngine.NET 2
- javascript 实例(-)
- CSS 背景偏移技术详解
- 报错!Syntax error,parameterized types are only available if source level is 5.0 解决方法
- 枚举类型映射
- 人生
- Windows Server 2003 IIS 配置网站出现问题及解决
- utf-8和gb2312乱码问题,延伸至中文编码乱码问题的解决(留坑以后有时间挖)
- WordPress:Akismet ----Feel the Power of BlogEngine.NET Spam Filtering
- 集合笔记