我做了个例子,供参考
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head>
<script language="javascript">
var l = 5;function chg(w)
{
if(w == "l")l = 5;
if(w == "r")l = -5;
window.setInterval("move()",70);
}
function move()
{
var n = document.all.Layer2.style.left;
n = n.replace(/[^\d|\-]*/gi,"");
n = parseInt(n);
document.all.Layer2.style.left = n + l;
if(l == 0) window.clearInterval();
}function stop()
{
l = 0;
}
</script>
<body>
<p align="center">
<a href="#" onmouseover=chg("l"); onmouseout=stop();><<</a> <a href="#" onmouseover=chg("r"); onmouseout=stop();>>></a>
<div id="Layer1" style="position:absolute; width:500px; height:100px; z-index:1">
<div id="Layer2" style="position:absolute; width:500; height:22; z-index:1; left: 0; top:0">
<table width="500" border="0">
<tr>
<td><a href="#">111</a></td>
<td><a href="#">222</a></td>
<td><a href="#">333</a></td>
<td><a href="#">444</a></td>
<td><a href="#">555</a></td>
<td><a href="#">666</a></td>
<td><a href="#">777</a></td>
<td><a href="#">888</a></td>
<td><a href="#">999</a></td>
<td><a href="#">000</a></td>
</tr>
</table>
</div>
</div>
</body>
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head>
<script language="javascript">
var l = 5;function chg(w)
{
if(w == "l")l = 5;
if(w == "r")l = -5;
window.setInterval("move()",70);
}
function move()
{
var n = document.all.Layer2.style.left;
n = n.replace(/[^\d|\-]*/gi,"");
n = parseInt(n);
document.all.Layer2.style.left = n + l;
if(l == 0) window.clearInterval();
}function stop()
{
l = 0;
}
</script>
<body>
<p align="center">
<a href="#" onmouseover=chg("l"); onmouseout=stop();><<</a> <a href="#" onmouseover=chg("r"); onmouseout=stop();>>></a>
<div id="Layer1" style="position:absolute; width:500px; height:100px; z-index:1">
<div id="Layer2" style="position:absolute; width:500; height:22; z-index:1; left: 0; top:0">
<table width="500" border="0">
<tr>
<td><a href="#">111</a></td>
<td><a href="#">222</a></td>
<td><a href="#">333</a></td>
<td><a href="#">444</a></td>
<td><a href="#">555</a></td>
<td><a href="#">666</a></td>
<td><a href="#">777</a></td>
<td><a href="#">888</a></td>
<td><a href="#">999</a></td>
<td><a href="#">000</a></td>
</tr>
</table>
</div>
</div>
</body>
解决方案 »
- JavaScript函数里面能用el表达式么?
- Exception."Could not convert JavaScript argument"nsresult: "0x80570009 (NS_ERROR
- javascript中this关键字
- DOM 有没有什么网上手册?
- ext js表单提交的问题
- javascript读取asp cookies出现乱码
- Ext fieldset问题请教
- 请大虾帮忙看看没有办法搞定JS的“相同来源策略”
- 请问有人能完全防止用户刷新页面吗? 包搬用鼠标单击刷新按钮,高分相送!
- javascript可以获得URL请求返回的错误信息么?
- [求救!求救!]最小化窗口用JavaScript写,不调有windows组件,在IE6.0能生效
- 菜鸟怎么也搞不懂的问题?进来的都有分
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head>
<script language="javascript">
var l = 5;
function over(w)
{
if(w == "l")l = 5; //如果层向右移
if(w == "r")l = -5; //如果层向左移
window.setInterval("move()",70);//每隔70毫秒重复执行move函数
}
function move() //移动层的函数
{
var n = document.all.Layer2.style.left; //取层的当前位置,得到的是一字符串
n = n.replace(/[^\d|\-]*/gi,""); //去掉除数字和负号的其它字符
n = parseInt(n); //将字符串转化成数字
document.all.Layer2.style.left = n + l; //设置层的新位置
if(l == 0)window.clearInterval(); //如果鼠标已不在移动链接上,让循环停止
}
function stop()
{
l = 0;
}
</script>
<body>
<p align="center"><br>
<a href="#" onmouseover=over("l"); onmouseout=stop();><<</a> <a href="#" onmouseover=over("r"); onmouseout=stop();>>></a>
<div id="Layer2" style="position:absolute; width:500; height:22; z-index:1; left: 0; top:0">
<table width="500" border="0">
<tr>
<td><a href="#">111</a></td>
<td><a href="#">222</a></td>
<td><a href="#">333</a></td>
<td><a href="#">444</a></td>
<td><a href="#">555</a></td>
<td><a href="#">666</a></td>
<td><a href="#">777</a></td>
<td><a href="#">888</a></td>
<td><a href="#">999</a></td>
<td><a href="#">000</a></td>
</tr>
</table>
</div>
</body>
</html>