• javascript放大图片


    核心代码收集于网络(IE6,7,8,Firefox/3.6.11和TT4.8下测试通过).

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
        <script type="text/javascript">
        function CreatePopup() {  
            var SetElementStyles = function( element, styleDict ) {  
                var style = element.style ;  
                for ( var styleName in styleDict )style[ styleName ] = styleDict[ styleName ] ;   
            }  
            var eDiv = document.createElement( 'div' );   
            SetElementStyles( eDiv, { 'position': 'absolute', 'top': 0 + 'px', 'left': 0 + 'px', 'width': 0 + 'px', 'height': 0 + 'px', 'zIndex': 1000, 'display' : 'none', 'overflow' : 'hidden' } ) ;  
            eDiv.body = eDiv ;  
           var opened = false ;  
           var setOpened = function( b ) {  
               opened = b;   
           }  
           var getOpened = function() {  
               return opened ;   
           }  
           var getCoordinates = function( oElement ) {  
               var coordinates = {x:0,y:0} ;   
               while( oElement ) {  
                   coordinates.x += oElement.offsetLeft ;  
                   coordinates.y += oElement.offsetTop ;  
                   oElement = oElement.offsetParent ;  
               }  
               return coordinates ;  
           }  
          return {
              htmlTxt : '',
              document : eDiv,
              isOpen : getOpened(),
              isShow : false,
              hide : function() {
                  SetElementStyles( eDiv, { 'top': 0 + 'px', 'left': 0 + 'px', 'width': 0 + 'px', 'height': 0 + 'px', 'display' : 'none' } ) ;
                  eDiv.innerHTML = '' ;
                  this.isShow = false ;
              },
              show : function( iX, iY, iWidth, iHeight, oElement ) {
                  if (!getOpened()) { document.body.appendChild( eDiv ) ; setOpened( true ) ; } ;
                  this.htmlTxt = eDiv.innerHTML ;
                  if (this.isShow) { this.hide() ; } ;
                  eDiv.innerHTML = this.htmlTxt ;
                  var coordinates = getCoordinates ( oElement ) ;
                  eDiv.style.top = ( iX + coordinates.x ) + 'px' ;
                  eDiv.style.left = ( iY + coordinates.y ) + 'px' ;
                  eDiv.style.width = iWidth + 'px' ;
                  eDiv.style.height = iHeight + 'px' ;
                  eDiv.style.display = 'block' ;
                  this.isShow = true ;
              }
          }  
       }
        var oPopup;//控制图片的展示
        if (!window.createPopup) {  
            oPopup=CreatePopup();
        }
        else{
            oPopup = window.createPopup();
        }  
        function FillOutImage(imgUrl,eventTag) {    
            with (oPopup.document.body) {        
                style.backgroundColor = "lightyellow";        
                style.border = "solid black 1px";        
                innerHTML = "<img src='" + imgUrl + "' width='100%' height='100%' />";     
            }    
            var event = eventTag||window.event;  
            oPopup.show(event.clientX + 80, event.clientY+10, 300, 250);//窗体的大小
        }
        </script>
        
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <img src="imgages/bg_cm.jpg" border="0" width="100" height="100" onmousemove="FillOutImage('imgages/bg_cm.jpg',event)"  onmouseout="oPopup.hide();"  alt=""/>
        </div>
        <div id="divHere"></div>
        </form>
    </body>
    </html> 

  • 相关阅读:
    链式结构(案例)
    基于JDK动态代理实现的接口链式调用(Fluent Interface)工具
    理解 OpenStack 高可用(HA)(3):Neutron 分布式虚拟路由(Neutron Distributed Virtual Routing)
    理解 OpenStack 高可用(HA)(2):Neutron L3 Agent HA 之 虚拟路由冗余协议(VRRP)
    Neutron 理解 (9): OpenStack 是如何实现 Neutron 网络 和 Nova虚机 防火墙的 [How Nova Implements Security Group and How Neutron Implements Virtual Firewall]
    Neutron 理解 (8): Neutron 是如何实现虚机防火墙的 [How Neutron Implements Security Group]
    Neutron 理解 (6): Neutron 是怎么实现虚拟三层网络的 [How Neutron implements virtual L3 network]
    Neutron 理解 (7): Neutron 是如何实现负载均衡器虚拟化的 [LBaaS V1 in Juno]
    Neutron 理解 (4): Neutron OVS OpenFlow 流表 和 L2 Population [Netruon OVS OpenFlow tables + L2 Population]
    Neutron 理解 (3): Open vSwitch + GRE/VxLAN 组网 [Netruon Open vSwitch + GRE/VxLAN Virutal Network]
  • 原文地址:https://www.cnblogs.com/mimengjiangnan/p/1861639.html
Copyright © 2020-2023  润新知