如何点击图片弹出文件选择框

代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
<title>无标题文档</title>
</head>
<body>
    
<input type="file" id="browse" size="1" style="position: absolute; width: 10px; filter: alpha(opacity=0);
        opacity: 0; top: 0px;"
 />
    
<img id="imgBlog" src="upload.gif" align="absmiddle" />

    
<script>
        
function ss() {
            
var img = document.getElementById("imgBlog");
            
var file = document.getElementById('browse');
            img.onmousemove 
= function(e) {
                
var x, y;
                
if (e) { x = e.clientX; y = e.clientY; }
                
else { x = event.x; y = event.y; }
                window.status 
= x + "," + y;
                file.style.left 
= (x - 10+ 'px';
                file.style.top 
= (y - 10+ 'px';

            };
            
        };
        ss();
    
</script>

</body>
</html>


posted on 2010-10-14 17:10  dongee  阅读(615)  评论(2编辑  收藏  举报