简体   繁体   English

使用网页登录到apache服务器

[英]Login to apache server using a web page

I have this code right here: 我在这里有这个代码:

 <html> <body style="color:white;background-color:#222222"> <center> <br> <input type="text" id="username"> Username</input> <br> <input type="text" id="password"> Password</input> <br><br> <button onclick="test()">Submit</button> <p id="url"/> <script type="text/javascript"> function test(){ var userInput = document.getElementById("username").value; var userPass = document.getElementById("password").value; document.getElementById("url").innerHTML = encodeURI('http://'+userInput+':'+userPass+'@'+window.location.hostname+':81/Home/'); } </script> </center> </body> </html> 

It outputs an url that works . 它输出的作品的网址。 It logs me into my password-protected folders when I specify the right password. 当我指定正确的密码时,它会将我登录到受密码保护的文件夹中。 Only problem, I want the "Submit" button to automaticly redirect me to the specified page instead of showing me the url. 唯一的问题是,我希望“提交”按钮自动将我重定向到指定的页面,而不是显示我的网址。

I tried everything. 我尝试了一切。 Please help. 请帮忙。 Thanks. 谢谢。

Please check this: 请检查一下:

function test(){
    var userInput = document.getElementById("username").value;
    var userPass = document.getElementById("password").value;
    location.href = encodeURI('http://'+userInput+':'+userPass+'@'+window.location.hostname+':81/Home/');
}

Instead of 代替

document.getElementById("url").innerHTML = etc 

make it 做了

window.location.href = etc 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM