js 技巧 (十)广告JS代码效果大全 【2】

2021-07-13 02:05

阅读:411

标签:图片   func   blog   art   settime   广告   head   val   float   

2.[鼠标感应] 
    与前面一个代码不同的是,当鼠标移动到广告图片上是可以感应显示另外设置好的广告大图效果,下面就是实现效果所需代码: 

function bigshow(){ 
    document.all.div_250.style.visibility = ‘visible‘; 
    document.all.div_80.style.visibility = ‘hidden‘; 
    } 
    function bighide(){ 
    document.all.div_80.style.visibility = ‘visible‘; 
    document.all.div_250.style.visibility = ‘hidden‘; 
    } 
   
    var ad_80= new Array(1); 
    var ad_250= new Array(1); 
   
    ad_80[0]=""; 
    ad_250[0]=""; 
   
    var imgheight; 
    var fubioleft; 
    window.screen.width>800 ? fubioleft=15:fubioleft=15 
   
    document.write(‘

‘); 
   
    ad_now = new Date(); 
    ad_id= ad_now.getSeconds() %1 
   
    var adhead1="
"; 
    var adhead2="
"); 
    self.onError=null; 
    currentX = currentY = 0; 
    whichIt = null; 
    lastScrollX = 0; lastScrollY = 0; 
    NS = (document.layers) ? 1 : 0; 
    IE = (document.all) ? 1: 0; 
    function heartBeat() { 
    if(IE) { 
    diffY = document.body.scrollTop; 
    diffX = document.body.scrollLeft; } 
    if(NS) { 
    diffY = self.pageYOffset; diffX = self.pageXOffset; } 
    if(diffY != lastScrollY) { 
    percent = .5 * (diffY - lastScrollY); 
    if(percent > 0) percent = Math.ceil(percent); 
    else percent = Math.floor(percent); 
    if(IE) document.all.floater_left.style.pixelTop += percent; 
    if(NS) document.floater_left.top += percent; 
    lastScrollY = lastScrollY + percent; 
    } 
    if(diffX != lastScrollX) { 
    percent = .5 * (diffX - lastScrollX); 
    if(percent > 0) percent = Math.ceil(percent); 
    else percent = Math.floor(percent); 
    if(IE) document.all.floater_left.style.pixelLeft += percent; 
    if(NS) document.floater_left.left += percent; 
    lastScrollX = lastScrollX + percent; 
    } 
    } 
   
    if(NS || IE) action = window.setInterval("heartBeat()",1);var ad_80= new Array(1); 
    var ad_250= new Array(1); 
   
    ad_80[0]=""; 
    ad_250[0]="";
   
    var imgheight; 
    var fubioleft; 
    window.screen.width>800 ? fubioleft=15:fubioleft=15 
   
    document.write(‘
‘); 
   
    ad_now = new Date(); 
    ad_id= ad_now.getSeconds() %1 
   
    function myload() 
    { 
    if (navigator.appName == "Netscape") 
    { 
    document.div_right_80.pageX=+window.innerWidth-130; 
    document.div_right_250.pageX=+window.innerWidth-300; 
    mymove(); 
    } 
    else 
    { 
    div_right_80.style.left=document.body.offsetWidth-130; 
    div_right_250.style.left=document.body.offsetWidth-300; 
    mymove(); 
    } 
    } 
   
    function mymove() 
    { 
    if(document.ns) 
    { 
    document.div_right_80.left=pageXOffset+window.innerWidth-130; 
    document.div_right_250.left=pageXOffset+window.innerWidth-300; 
    setTimeout("mymove();",20) 
    } 
    else 
    { 
    div_right_80.style.left=document.body.scrollLeft+document.body.offsetWidth-145; 
    div_right_250.style.left=document.body.scrollLeft+document.body.offsetWidth-300; 
    setTimeout("mymove();",20) 
    } 
    } 
   
    var adhead1="
"; 
    var adhead2="
"); 
   
    myload() 
   
    document.write ("
"); 
    self.onError=null; 
    currentX_right = currentY_right = 0; 
    whichIt_right = null; 
    lastScrollX_right = 0; lastScrollY_right = 0; 
    NS = (document.layers) ? 1 : 0; 
    IE = (document.all) ? 1: 0; 
    function heartBeat_right() { 
    if(IE) { 
    diffY_right = document.body.scrollTop; 
    diffX_right = document.body.scrollLeft; } 
    if(NS) { 
    diffY_right = self.pageYOffset; diffX_right = self.pageXOffset; } 
    if(diffY_right != lastScrollY_right) { 
    percent_right = .5 * (diffY_right - lastScrollY_right); 
    if(percent_right > 0) percent_right = Math.ceil(percent_right); 
    else percent_right = Math.floor(percent_right); 
    if(IE) document.all.floater_right.style.pixelTop += percent_right; 
    if(NS) document.floater_right.top += percent_right; 
    lastScrollY_right = lastScrollY_right + percent_right; 
    } 
    if(diffX_right != lastScrollX_right) { 
    percent_right = .5 * (diffX_right - lastScrollX_right); 
    if(percent_right > 0) percent_right = Math.ceil(percent_right); 
    else percent_right = Math.floor(percent_right); 
    if(IE) document.all.floater_right.style.pixelLeft += percent_right; 
    if(NS) document.floater_right.left += percent_right; 
    lastScrollX_right = lastScrollX_right + percent_right; 
    } 
    } 
   
    if(NS || IE) action = window.setInterval("heartBeat_right()",1); 
    function bigshow_right(){ 
    document.all.div_right_250.style.visibility = ‘visible‘; 
    document.all.div_right_80.style.visibility = ‘hidden‘; 
    } 
    function bighide_right(){ 
    document.all.div_right_80.style.visibility = ‘visible‘; 
    document.all.div_right_250.style.visibility = ‘hidden‘; 
    }document.write(‘‘); 
    document.write(‘‘); 
    document.write(‘‘);


评论


亲,登录后才可以留言!