且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

以HTML提交表单后重定向到页面

更新时间:2021-07-18 03:10:11

对于其他遇到相同问题的人,我自己也想出了办法.

For anyone else having the same problem, I figured it out myself.

    <html>
      <body>
        <form target="_blank" action="https://website.com/action.php" method="POST">
          <input type="hidden" name="fullname" value="Sam" />
          <input type="hidden" name="city" value="Dubai&#32;" />
          <input onclick="window.location.href = 'https://website.com/my-account';" type="submit" value="Submit request" />
        </form>
      </body>
    </html>

我要做的就是在表单上内联添加target ="_ blank"属性以内联在新页面中打开响应,并使用onclick提交按钮重定向另一页面.

All I had to do was add the target="_blank" attribute to inline on form to open the response in a new page and redirect the other page using onclick on the submit button.