我的JS实行不了跳转,不知道错在哪

我的JS实行不了跳转,不知道错在哪

问题描述:

regist.php中的一行

 <dd class="face"><img src="images/1.jpg" alt="头像选择" id="faceimg"/></dd>

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');
}
};

函数都错了,是byId,不是byld

 var faceimg = document.getElementById('faceimg');

你这不是跳转,而是弹出窗口,而弹出窗口可能被浏览器拦截了。

首先就是路径要保证正确,其次face这个窗口要确保是第一次创建。

你可以使用window.location.href