-1
<html>
<head><title></title></head>
<body>
<form action="https://oauth.vk.com/authorize?client_id=3343995&scope=photos,wall,offline&redirect_uri=http://example.com/vkontakte/auth&response_type=code" method="get">
<input type="submit" value="Auth">
</form>
</body>
</html>

你好。我遇到了这个 HTML 的问题。当我单击提交按钮时,我希望转到https://oauth.vk.com/authorize?client_id=3343995&scope=photos,wall,offline&redirect_uri=http://example.com/vkontakte/auth&response_type=code链接,但我去https://oauth.vk.com/authorize没有重定向。

4

1 回答 1

1

当您的表单使用method="get"时,查询参数将从您的操作属性中删除,并且表单元素将在 URL 的查询字符串中进行 URL 编码。

如果您可以使用 POST,则只需更改要使用的表单即可method="POST"。您仍然应该正确编码您的 URL 名称和值http://jsfiddle.net/9FmtW/3/

如果必须使用 GET,则必须将查询参数作为隐藏字段包含在表单中http://jsfiddle.net/9FmtW/这有利于正确地对查询字符串参数进行 URL 编码

<form action="https://oauth.vk.com/authorize" method="get">
  <input type="hidden" name="client_id" value="3343995" />
  <input type="hidden" name="scope" value="photos,wall,offline" />
  <input type="hidden" name="redirect_uri" value="http://example.com/vkontakte/auth" />
  <input type="hidden" name="response_type" value="code" />
  <input type="submit" value="Auth" />
</form>

在此处输入图像描述

您的网址中包含一个网址,您需要转义特殊的网址特定字符,例如&=

于 2013-01-08T00:30:18.087 回答