<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
var arImgs = [
'http://img5.cache.netease.com/cnews/2012/6/29/201206291228580c0ae.jpg',
'http://img6.cache.netease.com/cnews/2012/6/30/201206301612199c584.jpg',
'http://img1.cache.netease.com/cnews/2012/6/30/201206301334196ff3d.jpg',
'http://img6.cache.netease.com/cnews/2012/6/30/20120630130449974bb.jpg',
'http://img3.cache.netease.com/cnews/2012/6/30/201206301119029b4db.jpg'
], t, flagSTOP = false;function showRandImg(ar) {
document.getElementById('container').getElementsByTagName('img')[0].src = ar[Math.floor(Math.random() * (ar.length - 1))];
}
window.onload = function() {
t = window.setInterval('showRandImg(arImgs)', 1000);
var oImg = document.getElementById('container').getElementsByTagName('img')[0];
oImg.onclick = function() {
if (flagSTOP) window.setInterval('showRandImg(arImgs)', 1000);
else {
t = window.clearInterval(t);
flagSTOP = true;
}
}
}
</script>
</head><body>
<div id="container"><img src="http://img3.cache.netease.com/cnews/2012/6/30/201206300956573145b.jpg" /></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
var arImgs = [
'http://img5.cache.netease.com/cnews/2012/6/29/201206291228580c0ae.jpg',
'http://img6.cache.netease.com/cnews/2012/6/30/201206301612199c584.jpg',
'http://img1.cache.netease.com/cnews/2012/6/30/201206301334196ff3d.jpg',
'http://img6.cache.netease.com/cnews/2012/6/30/20120630130449974bb.jpg',
'http://img3.cache.netease.com/cnews/2012/6/30/201206301119029b4db.jpg'
], t, flagSTOP = false;function showRandImg(ar) {
document.getElementById('container').getElementsByTagName('img')[0].src = ar[Math.floor(Math.random() * (ar.length - 1))];
}
window.onload = function() {
t = window.setInterval('showRandImg(arImgs)', 1000);
var oImg = document.getElementById('container').getElementsByTagName('img')[0];
oImg.onclick = function() {
if (flagSTOP) window.setInterval('showRandImg(arImgs)', 1000);
else {
t = window.clearInterval(t);
flagSTOP = true;
}
}
}
</script>
</head><body>
<div id="container"><img src="http://img3.cache.netease.com/cnews/2012/6/30/201206300956573145b.jpg" /></div>
</body>
</html>
解决方案 »
- top.bottom.cols的问题
- dom获取所有子节点内容
- 看不明白的JS,高手们进来解释一下
- select关联问题,PHP语句,需要用到数据库
- 如何在页面中定义一个事件,当页面刷新时,就调用一个声音发出
- javascript怎么動態命名?
- 关于UBB中正则表达式使用的奇怪问题?(结贴王,在线等)
- 急急!!版本help!!请问如果用javascript或者php语言实现当打开查个面页时就要求安装或者运行某个程序,有没有相关的程序(在线等)
- 想实现一个功能 当选择表单select0里边的“产品分类“,然后自动探出另外一个select1表单,选择select1表单里边的分类信息搜索,选择表单
- 我想实现像delphi中的日期时间输入
- Opera浏览器代码调试工具有吗?就像chrome和IE那种按F12察看的。
- 急急急 求jsp+JavaScript写的树形目录实例代码?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function Init(){
this.is=0;
this.time="";
this.images=[];
this.image=document.images[0];
this.image.onclick=this.isStop.bind(this);
this.images.push("1.jpg");
this.images.push("2.jpg");
this.images.push("3.jpg");
this.images.push("4.jpg");
this.change();
}
Init.prototype.change=function(){
var r=parseInt(Math.random()*(this.images.length+1));
this.image.src=this.images[r];
this.time=window.setTimeout(this.change.bind(this),1000);
}
Init.prototype.isStop=function(){
if(this.is==0){
window.clearTimeout(this.time);
this.is=1;
}else{
this.change();
this.is=0;
}
}
window.onload=function(){
new Init();
}
</script>
</head><body>
<img src="1.jpg">
</body>
</html>
这样试试