JavaScript 在我的框架中不起作用?
我现在正在制作一个主页,并且我已经用框架集围绕“主页”做了一个边缘...这可能很愚蠢,但现在我的 JavaScript 由于某种原因无法工作?!
我想做的是使用 javascript 创建一个受用户名和密码保护的页面。脚本本身如下:
<代码> 函数登录(); {
var username = prompt("Skriv venligst dit brugernavn:" , "");
var password = prompt("Skriv venligst dit password:" , "");
var PassWords = new Array(46);
{
PassWords[0] = "username:password";
PassWords[1] = "username1:password1";
PassWords[2] = "and_so_on:and_so_on";
}
for (i = 0; i < PassWords.length; i++)
{
if (PassWords[i].indexOf(username) == 0)
{
var Split = koder[i].split(":");
var UserName = Split[0];
var PassWord = Split[1];
if (username == UserName && password == PassWord)
{
alert("Access Granted")
window.location="access.htm";
}
else
{
alert("Access Denied!")
window.location="no_access.htm";
}
}
}
}
请
帮助我! (: 主页的链接是 http://www.vestervang-dejret.dk/ -你可能不会理解它,因为它是丹麦语,但将鼠标悬停在“Dokumenter”并选择“Referer”,如果单击按钮,你将看不到任何反应......我尝试使用按钮和 onload-event 触发脚本,但是没有任何作用!请帮忙!
I am making a homepage at the moment and I have made an edge around the "main page" with frameset... that was probably stupid, but now my JavaScript for some reason doesn't work?!
What I want to do is make a username and password protected page using javascript. The script itself is as follows:
function logIn(); {
var username = prompt("Skriv venligst dit brugernavn:" , "");
var password = prompt("Skriv venligst dit password:" , "");
var PassWords = new Array(46);
{
PassWords[0] = "username:password";
PassWords[1] = "username1:password1";
PassWords[2] = "and_so_on:and_so_on";
}
for (i = 0; i < PassWords.length; i++)
{
if (PassWords[i].indexOf(username) == 0)
{
var Split = koder[i].split(":");
var UserName = Split[0];
var PassWord = Split[1];
if (username == UserName && password == PassWord)
{
alert("Access Granted")
window.location="access.htm";
}
else
{
alert("Access Denied!")
window.location="no_access.htm";
}
}
}
}
Please help me!! (: The link to the homepage is http://www.vestervang-dejret.dk/ - you probably won't understand it because it's danish but hover "Dokumenter" and select "Referater" and if you click the button you will see nothing happens... I've tried triggering the script with a button and the onload-event but nothing works! PLEASE HELP!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
去掉分号“;”在 login() 之后,
JavaScript 将其视为语句结束,而不考虑函数体。它仍然是有效的 JavaScript,但它不是函数定义。
Remove the semicolon ";" after login()
JavaScript is seeing that as the end of statement, and not taking into account the function body. It's still valid JavaScript, but it's not a function definition.