首页 > 代码库 > 关于当当网的js代码
关于当当网的js代码
/*window.onload = function(){
//获取所有的tab选项卡
var tabs = document.getElementById("tabsMin").getElementsByTagName("li");
var contents = document.getElementById("newbooks_main").getElementsByTagName("div");
for(var i = 0;i<tabs.length;i++){
tabs[i].index = i;
tabs[i].onmouseover = function(){
for(var j = 0;j<tabs.length;j++){
tabs[j].className = "";
contents[j].style.display = "none";
};
this.className = "cur";
contents[this.index].style.display = "block";
};
}
};*/
$(function () {
/*最新上架版块TAB切换效果*/
$("#tabsMin li").mouseover(function () {
$(this).addClass("cur").siblings().removeClass("cur");
$("div .bookSort").hide().eq($(this).index()).show();
});
//定时器
var nowRow=0;
function times(){
if(nowRow==$("#focus li").length) nowRow=0;
$("#focus li").eq(nowRow).addClass("cur").siblings().removeClass("cur");
$("#focusimg").attr("src","images/dd_scroll_"+(nowRow+1)+".jpg");
nowRow++;
}
var time=setInterval(times,1000);
//幻灯片
$("#focus li").mouseover(function(){
$(this).addClass("cur").siblings().removeClass("cur");
$("#focusimg").attr("src","images/dd_scroll_"+($(this).index()+1)+".jpg");
clearInterval(time);
});
$("#focus li").mouseout(function(){
time=setInterval(times,1000);
});
//浮动广告
$("#right").css({"position":"fixed","top":"100px"});
//关闭浮动广告
$("#dd_close").click(function(){
$(this).parent().hide();
});
/*右侧随鼠标滚动的广告图片
var rightT;
var rightR;
var objRight;
var rightWidth;
function place(){
objRight=document.getElementById("right");
rightWidth=document.getElementById("right1").width;
if(objRight.currentStyle){//IE浏览器
rightT=parseInt(objRight.currentStyle.top);
rightR=parseInt(objRight.currentStyle.right);
}
else{//fireFox浏览器
rightT=parseInt(document.defaultView.getComputedStyle(objRight,null).top);
rightR=parseInt(document.defaultView.getComputedStyle(objRight,null).right);
}
}
function move(){
objRight.style.top=rightT+parseInt(document.documentElement.scrollTop + document.body.scrollTop)+"px";
objRight.style.left=parseInt(document.documentElement.scrollLeft+document.body.scrollLeft)+parseInt(document.documentElement.clientWidth)-rightR-rightWidth+"px";
document.getElementById("dd_close").style.left="63px";
}
place();
window.onscroll=move;
右侧随鼠标滚动的广告图片关闭
objRight.onclick=function(){
objRight.style.display="none";
}*/
//下拉菜单
$("[alt=‘arrow‘]").parent().hover(
function(){
$("#dd_menu_top_down").show();
},
function(){
$("#dd_menu_top_down").hide();
}
);
//自动滚动广告
$("#dome2").html($("#dome1").html());
function timee(){
if($("#dome2")[0].offsetTop-$("#dome")[0].scrollTop<=0){
$("#dome")[0].scrollTop-=$("#dome1")[0].offsetHeight
}else{
$("#dome")[0].scrollTop++;
}
}
var start=setInterval(timee,1)
$("#dome").hover(
function(){
clearInterval(start);
},
function(){
start=setInterval(timee,1)
}
);
});
关于当当网的js代码