JavaScript 在我的框架中不起作用?

发布于 2024-09-10 06:27:33 字数 1245 浏览 7 评论 0原文

我现在正在制作一个主页,并且我已经用框架集围绕“主页”做了一个边缘...这可能很愚蠢,但现在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

胡渣熟男 2024-09-17 06:27:33

去掉分号“;”在 login() 之后,

JavaScript 将其视为语句结束,而不考虑函数体。它仍然是有效的 JavaScript,但它不是函数定义。

function logIn() {

 var username = prompt("Skriv venligst dit brugernavn:" , "");

var password = prompt("Skriv venligst dit password:" , "");
// ... etc...

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.

function logIn() {

 var username = prompt("Skriv venligst dit brugernavn:" , "");

var password = prompt("Skriv venligst dit password:" , "");
// ... etc...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文