Nhờ dịch đoạn code

function pass()
{
var pw, Eingabe;
pw=window.document.alinkColor;
Eingabe=prompt ("Please enter password");
if (Eingabe==pw)
{
window.location.href=String.fromCharCode(97,98,114,97,101)+".htm";
}
else
{
alert("Try again");
}
}
{
    var pw, Eingabe;
    pw=window.document.alinkColor;
    Eingabe=prompt ("Please enter password");
    if (Eingabe==pw)
    {
        window.location.href=String.fromCharCode(97,98,114,97,101)+".htm";
    }
    else
    {
        alert("Try again");
    }
}

Bạn nên sửa theo kiểu này để code dễ đọc hơn.

1 Like

đây là JavaScript hả bạn ? :hushed:

function pass() {
    var pw, Eingabe;
    pw = window.document.alinkColor; // pass là giá trị của thuộc tính alink trên thẻ body
    Eingabe = prompt("Please enter password"); // Yêu cầu người dùng nhập pass (ở trên)
    if (Eingabe == pw) {
        window.location.href = String.fromCharCode(97, 98, 114, 97, 101) + ".htm"; // Nếu nhập pass đúng thì chuyển đến trang /abrae.htm
    } else {
        alert("Try again"); // Nhập pass sai thì thông báo "Try again"
    }
}
1 Like
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?