惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Blog — PlanetScale
Blog — PlanetScale
博客园 - Franky
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
D
Docker
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
N
Netflix TechBlog - Medium
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Engineering at Meta
Engineering at Meta
H
Help Net Security
B
Blog
宝玉的分享
宝玉的分享

博客园 - 迷梦江南

DB2问题记录本 AS3无缝循环播放FLV flex开发零碎笔记,随时补充 AS3淡入淡出类 JQuey练习一 转“大型网站架构演变和知识体系” 转“大型高并发高负载网站的系统架构 ” 转“经验分享:大型高并发高负载网站的系统架构 ” 转“关于平台研发的一些想法” 转“国内图片网站Yupoo的架构” mootools 1-4 ajax C#测试代码段运行速度 - 迷梦江南 - 博客园 javascript网站导航栏 - 迷梦江南 - 博客园 QQ在线状态接口 - 迷梦江南 - 博客园 (转)Javascript在IE与Firefox下的差异 WebApplication与Profile购物车 网站发布后出现的两个问题 mootools实现搜索提示文本框修正版 ASP.NET查看本地磁盘下的子目录和文件信息
javascript放大图片 - 迷梦江南 - 博客园
迷梦江南 · 2010-10-26 · via 博客园 - 迷梦江南

核心代码收集于网络(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>