다음은 키워드를 입력하고 검색 엔진을 선택한 다음 "검색"버튼을 눌러 검색하는 작은 프로그램의 코드입니다. 그러나 Google은 나에게 POST를 남겨 두지 않는다. 내가 뭘 할 수 있니?Google에 게시 할 수 없습니까?
편집 : Yahoo와 Bing은 잘 작동합니다.
ERROR
405. That’s an error.
The request method POST is inappropriate for the URL
/search?q=computer. That’s all we know.
HTML
<form name="search" action="" method="Post" onSubmit="redirect()">
<input type="text" name="keyword"><br />
Google<input type="radio" name="ch" checked>
Yahoo!<input type="radio" name="ch">
Bing<input type="radio" name="ch"><br />
<input type="submit" value="Search">
</form>
, 제대로 포맷되지 않은 자바 스크립트
<script type="text/javascript">
var searchengine=[
"http://google.com/search?q=",
"http://search.yahoo.com/search?p=",
"http://bing.com/search?q="
];
function redirect()
{
var radioButtons = document.getElementsByName("ch");
for (var x = 0; x < radioButtons.length; x++) {
if (radioButtons[x].checked)
{
document.search.action = searchengine[x] + document.search.keyword.value;
}
}
}
</script>
GET 기능이 없습니다. – a1204773
window.location을 완전히 잊어 버렸습니다 ... 고마워 ... – a1204773
@Loclip : 양식 필드가 정확하면'GET '이 작동합니다. 구체적으로 말하자면,'keyword' 필드는'q'이어야하고, 제출하고자하는 URL에서'q'를 제거해야합니다. 왜냐하면 Google은'q'를 검색 용어로 기대하기 때문입니다. –