今天做网页两侧浮动广告图片,用js代码是实现,下面是一个*.js文件,在需要用到的网页加一句代码
src="*.js">即可使用,我可弄好的,分享给有需要朋友。
leftcode1="
href='/'
target='_blank'>
src='/images/xibao.jpg' width='120'
height='250'
border='0'>
src='/images/close.gif'
onClick='javascript:window.hide()' width='25' height='25'
border='0' vspace='3'
alt=''>
"
document.write(leftcode1);
rightcode2="
href='/'
target='_blank'>
src='/images/xibao.jpg' width='120'
height='250'
border='0'>
src='/images/close.gif'
onClick='javascript:window.hide()' width='25' height='25'
border='0' vspace='3'
alt=''>
"
document.write(rightcode2);
//调用'flash'的方法
//
HEIGHT=300 TYPE="application/x-shockwave-flash" id=ad
wmode=opaque>
lastScrollY=0;
function heartBeat(){
diffY=document.body.scrollTop;
percent=.3*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else
percent=Math.floor(percent);
document.all.young1.style.pixelTop+=percent;
document.all.young2.style.pixelTop+=percent;
lastScrollY=lastScrollY+percent;
}
function hide() {young1.style.visibility="hidden";young2.style.visibility="hidden";
}
window.setInterval("heartBeat()",1);