几个简单的js实例

鼠标悬停切换图片:

<html>
<head>
<script type="text/javascript">
function mouseOver()
{
document.getElementById('b1').src ="diaochan.jpg"
}
function mouseOut()
{
document.getElementById('b1').src ="noimage.gif"
}
</script>
</head>

<body>
<a href="#
"
onmouseover="mouseOver()" onmouseout="mouseOut()">
<img alt="Visit W3School!" src="noimage.gif" id="b1" onmouseover="alert('你的鼠标在图片上!')")/>
</a>
</body>
</html>

js显示天气预报:

<html>
<head><title></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></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;
}
</script>
</head>
<body onload="defau()">
<a href="
http://www.baidu.com/" id="1">百度</a>
<a href="
http://www.google.com.hk/" id="2">谷歌</a>
<a href="
http://www.youku.com/" id="3">优酷</a>
<a href="
http://www.tudou.com/" id="4">土豆</a>
<input id="Button1" type="button" value="选择" onclick="showtable()" /><br />
<input id="Button2" type="button" value="进入" onclick="openhref()" />
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值