日期:2014-05-16  浏览次数:20404 次

网站2侧广告js实现
<script language="javascript">
 	//左边
 <%
   	for(int j=0;j<list.size();j++){ 
   		AdvertiseModel model = (AdvertiseModel)list.get(j);
   		if("6".equals(model.getAdSeat())){
   
 %>
var left_img = "<DIV id=\"lovexin12\" style='left:22px;POSITION:absolute;TOP:69px;'><a href='http://<%=model.getAdUrl()%>' target='newForm'><img border=0 src='<%=basePath %>uploadPackage/<%=model.getImgUrl() %>' width='97' height='320'></a><br><img border=0 src=images/close.gif onClick='closeBanner();'></div>";
<%
	}}
%>
	
	 //右边
<%
   	for(int j=0;j<list.size();j++){ 
   		AdvertiseModel model = (AdvertiseModel)list.get(j);
   		if("7".equals(model.getAdSeat())){
   
%>
var right_img="<DIV id=\"lovexin14\" style='right:22px;POSITION:absolute;TOP:69px;'><a href='http://<%=model.getAdUrl()%>' target='newForm'><img border=0 src='<%=basePath %>uploadPackage/<%=model.getImgUrl() %>' width='97' height='320'></a><br><img border=0 src=images/close.gif onClick='closeBanner();'></div>"
<%}}%>
lastScrollY=0;
function closeBanner()
{
	document.getElementById("lovexin12").style.display	= 'none';
    document.getElementById("lovexin14").style.display	= 'none';
}
function heartBeat(){
var diffY;
if (document.documentElement && document.documentElement.scrollTop)
diffY = document.documentElement.scrollTop;
else if (document.body)
diffY = document.body.scrollTop
else
{/*Netscape stuff*/}
//alert(diffY);
percent=.1*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById("lovexin12").style.top=parseInt(document.getElementById("lovexin12").style.top)+percent+"px";
document.getElementById("lovexin14").style.top=parseInt(document.getElementById("lovexin12").style.top)+percent+"px";
lastScrollY=lastScrollY+percent;
//alert(lastScrollY);
}
document.write(left_img);
document.write(right_img);
window.setInterval("heartBeat()",1);
</script>

?