function hhh(e){
var e = e || window.event;
if(e.keyCode == 13){
findUsers();
alert("sss");
}
}
function findUsers(){
var account = $("#userAccount").val();
if(account == "" || account == null){
alert("请输入查找用户的id或名!");
return;
}
window.location = "$link.getContextURL()/sns/friendController/searchFriend?account="+account;
}
为什么用户按回车键后,页面无法跳转?求大侠知道
首先是你确保window.location =url这个正确,
然后
估计是你调用出现问题,兼容调用方式
window.location.href='地址'
可能是你这段代码问题吧
[code="java"]
window.location = "$link.getContextURL()/sns/friendController/searchFriend?account="+account;
[/code]
看看报错信息是什么?如果url出现问题,会出现“拒绝访问”
看看你注册keydown事件是否正确。
浏览器后台是否报错。
在findUsers函数最后加一句"return true", 问题原因很可能是你使用了submit提交但没有给定返回值。 如果不可以,尝试在你调用findUsers()后加一句"return true"。
给你一个基于JQUERY的
$(document).ready(function(){
$("input").bind("keyup",function(){
if (event.keyCode == 13) {
alert('click me!');
}
});
});