HTML 脚本 src=“” 使用按钮触发重定向
html script src="" triggering redirection with button
我有以下登录.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>
而且我还有名为脚本的其他文件夹,其中包含以下登录.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()
函数。
首先,您链接此处的文件:
<script src="../Script/login.js">
这将导致网站进入文件夹Script
中的文件,但是在第二段中,您说文件夹名称是
而且我还有名为脚本的其他文件夹,其中包含以下登录.js文件
所以,这是行不通的!因为您没有访问正确的文件。为此,请将代码编写为
<script src="/script/login.js"></script>
也尝试从代码开头删除..
。
这样,您将到达运行函数的 js 文件!
只是为了确保:
只是为了确保文件附加到HTML DOM,然后请打开开发人员工具(F12),并在网络工作区中记下浏览器向服务器发出的每个请求。通过这种方式,您将了解哪些文件已加载,哪些文件未加载,以及为什么没有加载!
祝你好运。
您的文件夹名称是scripts
?
改变
<script src="../Script/login.js">
自
<script src='scripts/login.js' type='text/javascript'></script>
我遇到了这个问题,但我发现这是一个权限问题,我将权限更改为 0744,现在它可以工作了。我不知道这是否是你的问题,但它对我有用。
您的文件夹名称是脚本。
并且您正在引用它,例如../script/login.js
还要确保脚本文件夹位于项目目录中
谢谢
相关文章:
- JavaScript下拉菜单-点击按钮并根据所选值重定向到url
- 我想重定向点击,然后更改按钮文本,我该怎么做
- 单击转盘按钮后重定向到另一个页面
- 如何在重定向到asp.net中单击按钮的下一页之前应用javascript警报
- 如何在单击按钮重定向页面时显示加载程序gif
- 如果答案正确,如何将提交按钮重定向到下一页
- 在同一功能上使用多个按钮重定向到不同的功能
- 根据单击的提交按钮重定向到php页面
- 类似AJAX的按钮重定向我,而不是执行AJAX调用
- 如何停止浏览器转发按钮重定向到页面
- 按钮重定向不起作用
- 通过单击按钮重定向到jQuery中的另一个网页
- 贝宝网站支付专业Iframe -支付与贝宝按钮重定向到贝宝
- 清除字段按钮(重定向不起作用)
- 从注销按钮重定向后,站点不加载索引样式
- 滚动到顶部按钮重定向到主页
- 在PayPal按钮重定向之前完成AJAX调用
- ngDialog关闭按钮重定向到其他页面
- Ajax按钮重定向在Selenium webdrivers上
- 后退按钮重定向脚本