<html>
<head>
<script>
~function () {
var box = document.getElementById("box");
var wrap = document.getElementById("wrap");
var conBegin = document.getElementById("conBegin");
var conBegin_width = getCss(conBegin,"width");
var timer = window.setInterval(move,10);
function move() {
wrap.scrollLeft++;
var curLeft = wrap.scrollLeft;
if (curLeft>=conBegin_width) {
wrap.scrollLeft = 0;
}
}
box.onmouseover = function () {
window.clearInterval(timer);
};
box.onmouseout = function () {
timer = window.setInterval(move,10);
};
}();
function getCss(curEle, attr) {
var val = null,reg = null;
if ("getComputedStyle" in window) {
val = window.getComputedStyle(curEle,null)[attr];
} else {
if (attr === "opacity") {
val = curEle.currentStyle["filter"];
reg = /^alpha\(opacity=(\d+(?:\.\d+)?)\)$/i;
val = reg.test(val) ? reg.exec(val)[1]/100 : 1;
} else {
val = curEle.currentStyle[attr];
}
}
reg = /^(-?\d+(\.\d+)?)(px|pt|rem|em)?$/i;
return reg.test(val) ? parseFloat(val) : val;
}
</script>
</head>
<body></body>
</html>
网友评论