我希望在我的用户登录后隐藏“登录 block ”。仍然看到登录部分非常令人困惑。我的用户认为他们的登录不起作用,但实际上他们已成功登录。我尝试将以下内容插入我的 CSS block ,但我需要一个条件使其在用户未登录时可见。
display: none;
这是我的这个部分的 HTML 代码:
<DIV id="hp-content">
<DIV id="hp-left-column">
<DIV id="hp-sign-header">
</DIV>
<DIV id="hp-sign">
<input type="textbox" class="ui-txt-general medium required" id="swsignin-txt-username" />
<input type="password" class="ui-txt-general medium required" id="swsignin-txt-password" />
<a title="Sign into my site." onclick="joelSignIn();" class="" id="swsignin-btn-submit"><img src="/cms/lib06/CA01000567/Centricity/Template/2/signin.png" alt="Sign In" /></a>
</DIV>
这是我为这一部分编写的 CSS 代码:
#hp-sign-header{
width: 288px;
height: 27px;
margin: 20px 0px 10px 0px;
background: transparent url(/cms/lib06/CA01000567/Centricity/Template/2/sign-header.png) no-repeat scroll top center;
}
#hp-sign{
width: 218px;
height: auto;
margin-left: 35px;
}
#swsignin-txt-username, #swsignin-txt-password {
border: 1px solid #0C304E;
color: #6994B9;
font-family: "Trebuchet MS",Arial,Helvetica,sans-serif;
font-weight: bold;
font-size: 15px;
line-height: 15px;
height: 47px;
margin: 0px 0px 10px 0px;
padding: 0px;
text-align: center;
width: 221px;
}
#swsignin-txt-username {
background: transparent url(/cms/lib06/CA01000567/Centricity/Template/2/username.png) no-repeat scroll top left;
}
#swsignin-txt-password {
background: transparent url(/cms/lib06/CA01000567/Centricity/Template/2/password.png) no-repeat scroll top left;
}
这是本节的 JAVASCRIPT 代码:
function joelSignIn(){
var data = "{Username: '" + addslashes($('#swsignin-txt-username').val()) + "',Password: '" + addslashes($('#swsignin-txt-password').val()) + "'} ";
var success = "window.location.reload()";
var failure = "if (result[0].reason === 'TOU') { DisplayTOU(); } else { CallControllerFailure(result[0].errormessage); }";
var callPath = "../site/SiteController.aspx/SignIn";
CallController(callPath, data, success, failure);
}
所以我的问题是,我是否需要插入 HTML 代码、CSS 代码和/或 JAVASCRIPT 代码才能使其正常工作?我需要插入的代码是什么以及在哪里插入?我曾尝试研究和玩耍,但无济于事。任何建议将不胜感激。谢谢!
最佳答案
您不能单独使用 javascript 登录。 Javascript 是一个 client-side语言,这意味着它只能在用户的计算机上运行。 “登录”表明您的访问者需要登录。这通常是在您用来托管网站的计算机上运行的数据库,通常称为服务器。这只能在 server-side 处完成.
关于javascript - 如何让登录部分在用户登录时消失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14531296/