js小问题能否给解答下
图片走马灯<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>跑马灯</title>
<script type="text/javascript">
function $(id) {
return document.getElementById(id);
}
var timer;
var maq;
var m1;
var m2;
var speed = 25;
//////////////////////////////////////////////////这个run具体什么作用详细说明一下?????????????????????????????????
function run() {
if (maq.scrollLeft >= m2.offsetWidth) {
maq.scrollLeft -= m2.offsetWidth;
}
else {
maq.scrollLeft += 2;
}
}
window.onload = function () {
maq = $("maq");
m1 = $("m1");
m2 = $("m2");
m2.innerHTML = m1.innerHTML;
timer = window.setInterval(run, speed);
maq.onmouseover = function () {
window.clearInterval(timer);
}
maq.onmouseout = function () {
timer = window.setInterval(run, speed);
}
}
</script>
</head>
<body>
<center>
//////////////////////////////////////////////这里的overflow都起到什么作用??????????????????????
<div id ="maq" style="overflow:hidden; width:400px; height:100px; border:solid 1px red; ">
<table>
<tr>
<td id = "m1">
<table>
<tr>
<td><img width="100" height="100" src="images/1.jpg"/></td>
<td><img width="100" height="100" src="images/2.jpg"/></td>
<td><img width="100" height="100" src="images/3.jpg"/></td>
<td><img width="100" height="100" src="images/4.jpg"/></td>
</tr>
</table>
</td>
<td id = "m2"></td>
</tr>
</table>
</div>
</center>
</body>
</html>
2 :) 哈哈有人 发表于 2013-8-27 11:18
2
什么意思 <html>
<head>
<title>跑马灯效果!!!</title>
<script type="text/javascript" language="javascript">
var timeId="";
function run(){
var title=document.title;
var firsttitle=title.charAt(0);
var remaintitle=title.substring(1,title.length);
document.title=remaintitle+firsttitle;
}
function leftrun(){
var title=document.title;
var firsttitle=title.charAt(0);
var remaintitle=title.substring(1,title.length);
document.title=remaintitle+firsttitle;
}
function rightrun(){
var title=document.title;
var righttitle=title.substring(title.length-1,title.length);
var remaintitle=title.substring(0,title.length-1);
document.title=righttitle+remaintitle;
}
var leftclearId;
var rightclearId;
function leftsetInter(){
leftclearId=setInterval('leftrun()',500);
clearInterval(rightclearId);
}
function rightsetInter(){
rightclearId=setInterval('rightrun()',500);
clearInterval(leftclearId);
}
</script>
</head>
<body>
<input type="button" value="跑马灯效果" onclick="timeId=setInterval('run()',500)"/>
<input type="button" value="停止" onclick="clearInterval(timeId)"/><br/><br/><br/>
<input type="button" value="向左滚动" onclick="leftsetInter()"/>
<input type="button" value="向右滚动" onclick="rightsetInter()"/>
</body>
</html>
qzuser 发表于 2013-9-3 15:44
跑马灯效果!!!
var timeId="";
论坛的缺点就是 好几天后才会有人看见贴
页:
[1]