javascript - 使用网页登录apache服务器

标签 javascript html apache

我这里有这段代码:

<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>

它输出一个 有效 的 url。当我指定正确的密码时,它会将我登录到受密码保护的文件夹中。 唯一的问题是,我希望“提交”按钮自动将我重定向到指定页面,而不是显示 url。

我什么都试过了。 请帮忙。 谢谢。

最佳答案

请检查:

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/');
}

关于javascript - 使用网页登录apache服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53586559/

相关文章:

java - 如何同时启动部署在tomcat中的所有应用

javascript - 使用 Python 在 Selenium 中运行 javascript

javascript - 如何让服务器在普通 PHP/SQL 网站后面执行任务?

javascript - 环回:更改模型文件夹结构

html - 元素在 Google Chrome 中居中,但在 Mozilla Firefox 中不居中

安卓FTP下载

javascript - 外部 JavaScript 文件中的英镑 (£) 和欧元 (€) 符号编码错误

javascript - 使用 getJson 进行 php 查询的变量

html - 段落大小的问题

java - iBatis/Java - 索引冲突