Form表单的action跳转URL问题

如题,在form表单中的action属性的值可以写成目标相对路径或URL绝对路径。在W3School中是这样描述的:

Where to send the form-data when the form is submitted.
Possible values:

  • An absolute URL - points to another web site (like action="http://www.example.com/example.htm")
  • A relative URL - points to a file within a web site (like action="example.htm")

现在我有下面的代码:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
  </head>
  <body>
    <form method="post" id="aspnetForm" name="loginform" action="https://securecn.englishtown.com/login/handler.ashx">
      <input name="username" type="hidden" value="xxxxxxxx"/>
      <input name="password" type="hidden" id="et-password" value="123456">
      <input name="p" type="hidden" id="txtPartner" value="Elef">
    </form>
    <script language="javascript">
      document.loginform.submit();
    </script>
  </body>
</html>

为了保密我把username给替换了。
把这些保存成html文件,在本地直接双击打开,是可以跳转到https://securecn.englishtown.com/login/handler.ashx并登陆成功的。
但,我把这个文件部署在服务器上,服务器会自动在文件所在的目录寻找login/handler.ashx,显然我服务器上没有这个东西,于是报出404。

为什么部署在服务器上就不能跳转了呢?

阅读 46.2k
4 个回答

不熟到服务器之后 你看看浏览器中的源码 有没有错

js直接执行form提交在浏览器来说是有一定的安全限制,就像你用js直接在页面执行window.open一样吧

http抓一下包就知道了

https://securecn.englishtown....
对网站来源进行了检测,你form跳转过去,对端网站拒绝访问又给你跳转回来了。

解决方案:通过ajax提交 这样他们就检测不到来源了~~

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题