我有一个登录页面,需要用户名和密码才能进入主页。
所以我有两个字段,一个是用户名,另一个是密码。输入用户名和密码后,你必须按回车键(从键盘),因为我已经隐藏了提交按钮。
我已经在mozilla firefox和opera浏览器中测试过了,它工作得很完美,但是在谷歌chrome中它不工作。请告诉我怎么做。
<%@ page import="java.sql.*" %>
<%@ page import="DB.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Spanwave</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>DiaEmr</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript">
function ccheck()
{
uid=document.getElementByName('uid').value;
cpass=document.getElementByName('cpass').value;
if(uid=="" || uid==null)
{
alert("Plz. Enter Your User ID");
document.f1.uid.focus();
return false;
}
if(cpass=="" || cpass==null)
{
alert("Plz. Enter Your Password");
document.f1.cpass.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<%
if(session.getAttribute("login")==null)
{
%>
<div id="menu-wrapper"> <<center><h2>Diabetes Surgery-Data Registry</h2> </center>
<div id="menu">
<ul>
</ul>
</div>
<!-- end #menu -->
</div>
<div id="banner"><a href="#"><img src="images/img01.jpg" width="1000" height="500" alt="rotating image" id="rotator"></a></div>
<div id="header-wrapper">
<div id="header">
<div id="logo">
<h1><a href="#">Dia<span>EMR</span></a></h1>
<p>Website design by <a href="http://www.spanwave.com">Spanwave</a></p>
</div>
</div>
</div>
<div id="wrapper">
<!-- end #header -->
<div id="page">
<div id="page-bgtop">
<div id="page-bgbtm">
<div id="sidebar">
<ul>
<li>
<h2>Portal Login</h2>
<div >
<form id="f1" name="f1" method="post" action="authentication.jsp" onsubmit="return ccheck()">
User Name<input type="text" name="uid" id="search-username" value="" />
Password<input type="password" name="cpass" id="search-password" value="" />
<input type="submit" id="search-submit" value="" /><br><br>New User<a href="UserRegistration.jsp">Register </a>
</form>
</div>
</ul>
</div>
<!-- end #sidebar -->
<div id="content">
<div class="post">
<h2 class="title">Welcome to DiaEmr </h2>
<div style="clear: both;"> </div>
<div class="entry">
<p>welcome to all the <strong>"Workshop on Ileal Interposition".</strong>,
<b>Brazil</b> to inaugurate & launch this very important Data Registry<br>
Key features of the solution-<br>
-Electronics Medical Records<br>
-Data Analysis<br>
-Easy Appointment Scheduling<br>
-Patient Reminder<br>
-Anytime,Anywhere Access<br>
-Highly Secured Data<br>
-Rich User Interface
</div>
</div>
</div>
</div>
</div>
<div style="clear: both;"> </div>
</div>
<!-- end #content -->
<div style="clear: both;"> </div>
</div>
</div>
</div>
<!-- end #page -->
</div>
<div id="footer">
<p>© 2013 Spanwave.com | Design by <a href="http://www.spanwave.com">Spanwave</a>.</p>
</div>
<!-- end #footer -->
<script type="text/javascript">
(function() {
var rotator = document.getElementById('rotator');
var imageDir = 'images/';
var delayInSeconds = 5;
// list image names
var images = ['img02.jpg', 'img03.jpg', 'img04.jpg', 'img01.jpg'];
// don't change below this line
var num = 0;
var changeImage = function() {
var len = images.length;
rotator.src = imageDir + images[num++];
if (num == len) {
num = 0;
}
};
setInterval(changeImage, delayInSeconds * 1000);
})();
</script>
<%}else{response.sendRedirect("frameSet.jsp");}%>
</body>
</html>
2条答案
按热度按时间whitzsjs1#
浏览器可能没有将Enter键解释为“提交”。我遇到过类似的问题,我使用了一个事件处理程序,它监听所需的键击并通过JavaScript进行提交。类似于以下内容:
不是最好的代码,但它可能会让你朝着正确的方向前进。
guicsvcw2#
删除您写了两次的srcipt
并给予不同的ID
和函数ccheck()尝试这样编辑