我在设计文件夹中有以下用于登录的 login.html 页面。
<html>
<head>
<title>Login Page</title>
<script src="../Script/login.js">
</script>
</head>
<body>
<h3> Login</h3>
<form name="login">
Location code : <select name="ddl1"><br>
<option value="loc1" size=20>LH</option>
<option value="loc2">AT</option>
<option value="sel" selected>-------select------</option>
</select>
<br><br>
Enter UserName : <input type="Text" name="inp1" size=20><br><br>
Enter Password : <input type="password" name="pwd1" size=20><br><br>
<button type="button" name="login" onclick="log()">Login</button>
</form>
</body>
</html>
而且我还有一个名为 scripts 的文件夹,其中包含以下 login.js 文件
function log()
{
var li=parent.head.document.getElementById('lin');
var lo=parent.head.document.getElementById('lou');
var passid = document.login.pwd1.value;
var passid_len = passid.length;
var un=document.login.inp1.value;
var e = document.getElementById("ddl1");
var strUser = e.options[e.selectedIndex].value;
if(strUser=="loc1" || strUser=="loc2")
{
if (passid_len >= 5)
{
if(un=="admin")
{
parent.nav1.location.href = 'nav_admin.html';
document.write("Hello admin");
li.style.display = "none";
lo.style.display = "";
}
else if(un=="clerec")
{
parent.nav1.location.href = 'nav_clerk_reception.html';
document.write("Hello reception clerk");
li.style.display = "none";
lo.style.display = "";
}
else if(un=="cledep")
{
parent.nav1.location.href = 'nav_clerk_departemnt_operations.html';
document.write("Hello dept clerk");
li.style.display = "none";
lo.style.display = "";
}
else if(un=="guest")
{
parent.nav1.location.href = 'nav_guest.html';
document.write("Hello Guest");
li.style.display = "none";
lo.style.display = "";
}
else
{
document.write("Wrong user name and password");
}
}
else
{
document.write("password should be minimum 5 characters");
}
}
else
{
document.write("Choose Location");
}
}
function fnlog1()
{
var lo=parent.head.document.getElementById('lou');
var li=parent.head.document.getElementById('lin');
lo.style.display = "none";
li.style.display = "";
parent.nav1.location.href = 'navigate.html';
}
当我单击log in
按钮时没有任何作用....没有重定向发生....html页面不调用log()
函数....