<marquee
scrolldelay="100"
direction="up"
onmouseover="this.stop()"
onmouseout="this.start()"><img
src="xxxxxxx"></marquee>
其中scrolldelay="100"
===>指滚动延迟时间,单位是毫秒ms,默认为90ms
direction="up"
===>指滚动方向,默认从左往右,可取的值为:up,down,left,right
onmouseover="this.stop()"
===>指鼠标悬停在图片上时,图片静止
onmouseout="this.start()"
===>指鼠标离开图片时,图片运动
希望对您有所帮助
自动滚动,主要思路是用js自带的setInterval方法。
定义和用法
setInterval() 方法可按照指定的周期(以毫秒计)来调用函数或计算表达式。
setInterval() 方法会不停地调用函数,直到 clearInterval() 被调用或窗口被关闭。由 setInterval() 返回的 ID 值可用作 clearInterval() 方法的参数。
语法
setInterval(code,millisec[,"lang"])
参数
code 必需。要调用的函数或要执行的代码串。
millisec 必须。周期性执行或调用 code 之间的时间间隔,以毫秒计。
返回值
一个可以传递给 Window.clearInterval() 从而取消对 code 的周期性执行的值。
简单的例子,仅供参考:
<style>*{ margin:0 padding:0 list-style:none}
#box{ width:840px border:1px solid #000 height:210px margin:30px auto position:relative overflow:hidden}
#box ul{ position:absolute left:0 top:0}
#box ul li{ width:200px height:200px float:left padding:5px}
</style>
<script>
window.onload=function(){
var oBox=document.getElementById('box')
var oUl=oBox.children[0]
var aLi=oUl.children
//复制一份内容
oUl.innerHTML+=oUl.innerHTML
oUl.style.width=aLi.length*aLi[0].offsetWidth+'px'
setInterval(function(){
var l=oUl.offsetLeft+10
if(l>=0){
l=-oUl.offsetWidth/2
}
oUl.style.left=l+'px'
},30)
}
</script>
</head>
<body>
<div id="box">
<ul>
<li><img src="img/1.jpg" width="200"></li>
<li><img src="img/2.jpg" width="200"></li>
<li><img src="img/3.jpg" width="200"></li>
<li><img src="img/4.jpg" width="200"></li>
</ul>
</div>
</body>
<script language="javascript" type="text/javascript">//图片滚动展示 Start
var counts = 4
//大图//
img1 = new Image()
img1.src = 'images/1.jpg'
img2 = new Image()
img2.src = 'images/2.jpg'
img3 = new Image()
img3.src = 'images/3.jpg'
img4 = new Image()
img4.src = 'images/4.jpg'
var smallImg = new Array()
//小图
smallImg[0] = 'images/index_adb1.gif'
smallImg[1] = 'images/index_adb2.gif'
smallImg[2] = 'images/index_adb3.gif'
smallImg[3] = 'images/index_adb4.gif'
//链接地址
url1 = new Image()
url1.src = ' http://www.baidu.com'
url2 = new Image()
url2.src = ' http://www.qzxtg.com'
url3 = new Image()
url3.src = ' http://www.soso.com'
url4=new Image()
url4.src=' http://www.sina.com.cn'
//alt值
alt1 = new Image()
alt1.alt = ''
alt2 = new Image()
alt2.alt = ''
alt3 = new Image()
alt3.alt = ' '
alt4 = new Image()
alt4.alt=''
////欢迎来到标准之路.
var nn = 1
var key = 0
function change_img() {
if (key == 0) {
key = 1
} else if (document.all) {
document.getElementById("pic").filters[0].Apply()
document.getElementById("pic").filters[0].Play(duration = 2)
}
eval('document.getElementById("pic").src=img' + nn + '.src')
eval('document.getElementById("url").href=url' + nn + '.src')
eval('document.getElementById("pic").alt=alt' + nn + '.alt')
if (nn == 1) {
document.getElementById("url").target = "_blank"
document.getElementById("url").style.cursor = "pointer"
} else {
document.getElementById("url").target = "_blank"
document.getElementById("url").style.cursor = "pointer"
}
for ( var i = 1i <= countsi++) {
document.getElementById("xxjdjj" + i).className = 'axx'
}
document.getElementById("xxjdjj" + nn).className = 'bxx'
nn++
if (nn >counts) {
nn = 1
}
tt = setTimeout('change_img()', 7000)
}
function changeimg(n) {
nn = n
window.clearInterval(tt)
change_img()
}
function imageshow() {
document.write('<div class="picshow_main">')
document.write('<div><a id="url"><img id="pic" class="imgbig" /></a></div>')
document.write('<div class="picshow_change">')
for ( var i = 0i <countsi++) {
document.write('<a href="javascript:changeimg(' + (i + 1)
+ ')" id="xxjdjj' + (i + 1)
+ '" class="axx" target="_self"><img src="' + smallImg[i]
+ '"></a>')
}
document.write('</div></div>')
change_img()
}
//图片滚动展示 End
</script>
<script language="javascript" type="text/javascript">
imageshow()
</script>