HTML中点击图片为什么会跳转网页,我没有写啊

<td><input type="image" value="OK" src="image/eye.gif" width="30" height="20" onClick="change_passwd();"></td>
function change_passwd()
{
var my_type = document.getElementById("W_passwd").type;
var temp = document.getElementById("W_passwd").value;
if(my_type=="password")
document.getElementById("pass").innerHTML = "<input type=text id=W_passwd>";

else
document.getElementById("pass").innerHTML = "<input type=password id=W_passwd>";

document.getElementById("W_passwd").value = temp;
}
这就是全部代码,为什么我点击图片之后会跳转网页呢?

  你好,是因为type="image“了,这个作用和type="submit"的效果是一样的,都会提交这个表单,所以就会造成跳转网页追问

请问有没有什么办法让他不跳转,只是刷新网页呢

追答

  你好,去掉type="image",或者就用普通的标签就好了,让他走你的点击事件,你就可以控制了

追问

就直接这样子跳转执行JS吗?还是具体怎么写。。image这个标签没有用过。。能给写个例子吗。。
搞定啦!!!谢啦,同样谢谢二楼!!

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-01-30
这应该不会跳转的啊,你浏览器刷新看看追问

。。。但是他就是跳转了。。好几次都是,如果我type=button就不会,所以type=image应该像一楼说的类似type=subbmit一样吧

追答

image是图片的意思啊,我试过的,没有跳转,image != subbmit ,而且你连跳转的地址都没有,他跳到哪去啊