重要なお知らせ

「教えて! goo」は2025年9月17日(水)をもちまして、サービスを終了いたします。詳細はこちら>

電子書籍の厳選無料作品が豊富!

Googleの提供する検索窓を自サイトに設置しWEB2.0風にページ上に
オーバーレイさせて結果を表示する"カスタム検索"について質問です。

以下がそのサービスが吐き出すコードです。(idっぽいのは一部XXXとかにしています)

<form action="" id="searchbox_XXX:XXXcwe" onsubmit="return false;">
<div>
<input type="text" name="q" size="40"/>
<input type="submit" value="検索"/>
</div>
</form>
<script type="text/javascript" src="​http://www.google.com/coop/cse/brand?form=search …

<div id="results_xxx:xxxcwe" style="display:none">
<div class="cse-closeResults">
<a>&times; 閉じる</a>
</div>
<div class="cse-resultsContainer"></div>
</div>

<style type="text/css">
@import url(​http://www.google.com/cse/api/overlay.css);
</style>

<script src="​http://www.google.com/uds/api?file=uds.js&v=1.0& …​ type="text/javascript"></script>
<script src="​http://www.google.com/cse/api/overlay.js"​ type="text/javascript"></script>
<script type="text/javascript">
function OnLoad() {
new CSEOverlay("xxx:xxx",
document.getElementById("searchbox_xxx:xxx"),
document.getElementById("results_xxx:xxx"));
}
GSearch.setOnLoadCallback(OnLoad);
</script>

これで"検索"をクリックするとオーバーレイ表示されます。
これを"検索"ボタンクリックではなくjavascriptのsubmitで実行したいのです。
例えば

<script language="javascript">
function submitG() {
document.myForm.submit();
}
</script>

↑submitG()を実行しても検索結果を表示してくれません。
submit自体は実行しているようなのですが。。

どなたか分かる方お願いします。

A 回答 (1件)

document.myFormはどこにあるの?



異なるドメインの場合は、↑を修正しても効かない可能性あり。
    • good
    • 0
この回答へのお礼

>document.myFormはどこにあるの?

すいません。実際は・・・

<form name="myForm" action="" id="searchbox_XXX:XXXcwe" onsubmit="return false;">

といった感じです。その上で機能しません。

"異なるドメインの場合は"というのはクロスドメイン問題でしょうか。
その場合、実行させるにはどのような措置が必要でしょうか。。

お礼日時:2009/03/06 20:56

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!