2013-10-06 4 views
0

Google 맞춤 검색을 사용하고 있으며 Jquery로 자신의 div를 사용하여 양식을 제출하고 싶습니다. 내가 행운과 함께 많은 일을했는데,이 그들 중 하나입니다Jquery로 Google 맞춤 검색을 제출하십시오.

구글 코드 :

<script> 
    (function() { 
    var cx = 'partner-pub-2789521296837340:9402765321'; 
    var gcse = document.createElement('script'); 
    gcse.type = 'text/javascript'; 
    gcse.async = true; 
    gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + 
     '//www.google.com/cse/cse.js?cx=' + cx; 
    var s = document.getElementsByTagName('script')[0]; 
    s.parentNode.insertBefore(gcse, s); 
    })(); 
</script> 


<gcse:search></gcse:search> 

JQuery와 부분 :

$(document).ready(function() { 

$("div.button").click(function() { 
    $("form.gsc-search-box").submit(); 
    return false; 
}); 


}); 

라이브 예 : 우리는 할 수 없습니다 JsFiddle

답변

2

제출 양식 (즉, Google은 내부적으로 jQuery를 사용하여 생성)을 제출하십시오. 모양과 느낌을 변경하려면 코드를 변경해야합니다. 여기에 당신이 찾고있는 하나입니다

<form id="cse-search-box" action="http://google.com/cse"> 
    <input type="hidden" name="cx" value="YOUR SEARCH ENGINE ID goes here" /> 
    <input type="hidden" name="ie" value="UTF-8" /> 
    <input type="text" name="q" size="31" /> 
    <input type="submit" name="sa" value="Search" /> 
</form> 
<img src="http://www.google.com/cse/images/google_custom_search_smwide.gif"> 

참조 : https://support.google.com/customsearch/answer/1351747?hl=en

DEMO FIDDLE

+0

매우 :) 검색 결과가 열 만드는 방법에 대한 어떤 생각을 가지고 있습니까 주셔서 감사합니다 같은 페이지? – Youss

+1

api 확인 : https://developers.google.com/custom-search/docs/element – Unknown

+0

링크를 제공해 주셔서 감사합니다. – Youss

관련 문제