js图片滚动

<script >
var imgc = 1;//图片序列开始
var imgm = 5;//图片序列结束
var flag = 1;//标记鼠标移动
var tm;//定时器
//自动循环播放图片


function cgimg(){
if(flag==0)return;
var mimg = document.getElementById("mimg");
mimg.src = ""+imgc+".jpg";
imgc++;
if(imgc>imgm)imgc=1;
tm = window.setTimeout("cgimg()",1000);
}
//鼠标移动到图片上
function imgstop(){
flag = 0;
window.clearTimeout(tm);
}
//鼠标移动到图片外
function imgstart(){
flag = 1;
tm = window.setTimeout("cgimg()",1000);
}
//单击按钮时
function moimg(imgurl){
window.clearTimeout(tm);
var mimg = document.getElementById("mimg");
mimg.src = imgurl;
}
//初始化按钮
function initbtn(){
var mimg = document.getElementById("imgdiv");
var divtop = parseInt(mimg.style.top);
var divhei = parseInt(mimg.style.height);
var mdivtop= divtop+divhei-30;


var divleft = parseInt(mimg.style.left);
var divwid = parseInt(mimg.style.width);
var mdivleft = divleft+divwid-(imgm-imgc)*25;

var btndiv = document.getElementById("btndiv");
for(i=imgc,j=1;i<=imgm;i++,j++){

btndiv.innerHTML = btndiv.innerHTML + " <a style=\"cursor:hand\" onmouseover=\"moimg('"+i+".jpg')\" onmouseout=\"imgstart()\">"+j+"</a> | ";
}

}

function showdiv(){
var mydiv = document.getElementById("mydiv");
mydiv.style.height=200;
}
function dispdiv(){
var mydiv = document.getElementById("mydiv");
mydiv.style.height=30;

}
function initdiv(){
var mydiv = document.getElementById("mydiv");
var winwidth = window.document.body.clientWidth;
var winheight = window.document.body.clientHeight;
var dheight =  parseInt(mydiv.style.height);
var dwidth =  parseInt(mydiv.style.width);
mydiv.style.top = winheight - dheight;
mydiv.style.left = winwidth - dwidth;

removediv();
}
function removediv(){
var mydiv = document.getElementById("mydiv");
var sheight = window.document.body.scrollTop;
var winheight = window.document.body.clientHeight;
var swidth = window.document.body.scrollLeft;
var winwidth = window.document.body.clientWidth;

var divh = sheight+winheight-parseInt(mydiv.style.height);
mydiv.style.top = divh;
var divw = swidth+winwidth-parseInt(mydiv.style.width);
mydiv.style.left = divw;

window.setTimeout("removediv()",20);
}

</script>

你可能感兴趣的:(J#)