| 
                        
                            |  当前位置:文章中心 >> Jquery_Ajax_Javascript |  
                        
                            | 
                                    
                                        | JS鼠标悬停显示缩略图 |  
                                        | 夜鹰教程网 来源:www.yyjcw.com                                      日期:2016-11-15 17:45:07 |  
                                    
                                        | 
 这篇文章不能解决你的问题?我们还有相关视频教程云课堂 全套前端开发工程师培训课程 微信号:yyjcw10000 QQ:1416759661  远程协助需要加QQ! 业务范围:视频教程|程序开发|在线解答|Demo制作|远程调试| 点击查看相关的视频教程。 技术范围:全端开发/前端开发/webapp/web服务/接口开发/单片机/C#/java/node/sql server/mysql/mongodb/android/。  
 
 |  
                                    
                                        | 
    
        
            | // JScript 文件 showPhoto =
 {
 containerID:’container’,
 init:function()
 {
 if(!document.getElementById||!document.createTextNode)
 
 {return;}
 //取到table标签
 showPhoto.table=document.getElementsByTagName(’table’);
 if(!showPhoto.table){return;}
 //取到姓名的超链接
 var namelinks=document.getElementsByTagName(’a’);
 showPhoto.all=namelinks.length;
 
 for(var i=0;i<showPhoto.all;i++)
 {
 namelinks[i].attachEvent(’onmouseover’,showPhoto.show);
 
 namelinks[i].attachEvent(’onmouseout’,showPhoto.hide);
 }
 
 showPhoto.creatContainer();
 },
 
 show: function(e)
 {
 var t=window.event.srcElement;
 var x=t.offsetLeft;
 var y=t.parentNode.offsetTop;
 //alert(x+’+’+y);
 var str=new String(t);
 //alert(str);
 var photoURL=’http://localhost:1903/List’+str.slice
 (str.indexOf("~")+1,str.length);
 //alert(photoURL);
 showPhoto.setPic(photoURL);
 showPhoto.c.style.top=y+190;
 showPhoto.c.style.left=x-120;
 //showPhoto.c.style.width=100;
 showPhoto.c.style.position=’absolute’;
 },
 
 creatContainer:function()
 {
 showPhoto.c=document.createElement(’div’);
 showPhoto.c.id=showPhoto.containerID;
 var p=document.createElement(’p’);
 
 showPhoto.c.appendChild(p)
 if(!showPhoto.table[0]){return;}
 showPhoto.table[0].parentNode.appendChild(showPhoto.c);
 },
 
 hide:function()
 {
 var p=showPhoto.c.getElementsByTagName(’p’)[0];
 p.innerHTML=’’;
 },
 
 setPic:function(pic)
 {
 
 //注意此处的[0]不可丢
 var picture=showPhoto.c.getElementsByTagName(’p’)[0];
 picture.innerHTML=’’;
 
 showPhoto.c.className=’show’;
 var i=document.createElement(’img’);
 i.setAttribute(’src’,pic);
 if(i.width>200)
 {
 i.width=180
 }
 if(i.height>250)
 {
 i.height=250
 }
 picture.appendChild(i);
 }
 }
 window.onload=showPhoto.init;
 |  |  | 
                                    
                                        |  热门服务/教程目录 |  
                                        | 
 
                                                 客服电话:153 9760 0032购买教程QQ:1416759661 |  |  |