如何使用javascript从一个页面转到另一个页面? [英] How to go from one page to another page using javascript?

查看:186
本文介绍了如何使用javascript从一个页面转到另一个页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户有效,则从管理页面开始,浏览器应该转到另一个页面。

From an admin page if the user is valid then the browser should go to another page.

当用户输入他的用户名和密码时,点击OK按钮然后显示另一个页面,登录页面自动关闭。

When a user enters his user name and password, then clicks the OK button then another page is displayed and the login page is automatically closed.

如何使用JavaScript执行此操作?

How can I do this with JavaScript?

推荐答案

简单地使用javascript重定向浏览器:

To simply redirect a browser using javascript:

window.location.href = "http://example.com/new_url";

要重定向并提交表单(即登录详细信息),不需要javascript:

To redirect AND submit a form (i.e. login details), requires no javascript:

<form action="/new_url" method="POST">
   <input name="username">
   <input type="password" name="password">
   <button type="submit">Submit</button>
</form>

这篇关于如何使用javascript从一个页面转到另一个页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆