js实例:几个简单的js实例

 

鼠标悬停切换图片:
<html>
<head>
<script type="text/javascript">
function mouseOver()
{
document.getElementById("b1").src ="diaochan.jpg"
}
function mouseOut()
{
document.getElementById("b1").src =http://www.cxybl.com/html/wyzz/JavaScript_Ajax/20130114/"noimage.gif"
}
</script>
</head>
<body>
<a href="#"
onmouseover="mouseOver()" onmouseout="mouseOut()">
<img alt="Visit W3School!" src=http://www.cxybl.com/html/wyzz/JavaScript_Ajax/20130114/"noimage.gif" id="b1" onmouseover="alert("你的鼠标在图片上!")")/>
</a>
</body>
</html>
js显示天气预报:
<html>
<head><title>www.cxybl.com</title>
<script type="text/javascript">
</script>
</head>
<body >
<div>
<iframe src="http://m.weather.com.cn/m/pn11/weather.htm" width="480" height="70" frameborder="1"></iframe>
</div>
</body>
</html>
js利用焦点实现选择网站:
<!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>www.cxybl.com</title>
<script type="text/javascript">
var i = 1;
var focusid;
function defau() {
document.getElementById("1").focus();
focusid=1;
}
function showtable() {
var id = i + 1;
document.getElementById(id).focus();
focusid=id;
i++;
if (i == 4) {
i = 0;
}
}
function openhref() {
var href = document.getElementById(focusid).href;
document.location = href;

 

 

 

 
 
 

本站永久域名

www.iulei.com

爱优磊个人网站由站长制作并维护

爱优磊保留本网页的设计版权,任何人在未经许可情况下不得套用。

Copyright ©2015 All rights reserved. 京ICP备14003788