face.js 以下window.onload=function(){
var faceimg=document.getElementByld('faceimg');
faceimg.onclick=function(){
window.open('face.php','face','width=400,height=400,top=0,left=0,scrollbars=1');
}
};
这段点击图片出新窗口的代码对否?
为什么我总是无效呢?
<dd class="face"><img src="/face/0.gif" alt="头像选择" id="faceimg"/></dd>

解决方案 »

  1.   

    var faceimg=document.getElementByld('faceimg');这行中的getElementByld写错了,应该是getElementById
      

  2.   

    ++
    eft=0,scrollbars=1');
    scrollbars参数值是 yes或no吧?
      

  3.   

    你是想做一个什么样的效果?是单击一张图片,打开一个窗口吗?如果这样的话,为什么不直接写他的单击事件呢,在<img>标签那里直接写onclick='方法名'就可以了
      

  4.   

    不会吧,以下是我本地测试的代码,在IE测试过没有问题
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
        <script type="text/javascript" language="javascript">
    window.onload=function(){
    var faceimg=document.getElementById('faceimg');
    faceimg.onclick=function(){
    window.open('face.php','face','width=400,height=400,top=0,left=0,scrollbars=1');
    }
    };
        </script>
    </head>
    <body>
     <dd class="face"><img src="/face/0.gif" alt="头像选择" id="faceimg"/></dd>
    </body>
    </html>
      

  5.   

    谢谢 iamaitman    我重新打了一遍  正常了~~但没发现哪里错了---