0

Google 検索ボックスの Java スクリプトを作成し、iWeb に適用しました。うまく表示されますが、検索しても応答しません。

コードは次のとおりです。

 <!-- Put the following javascript before the closing </head> tag. -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script>
(function() {
var cx = '012476238773441236228:ivxtfsk4-uc';
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>

<!-- Place this tag where you want both of the search box and the search results to render   -->
<gcse:search></gcse:search>
4

1 に答える 1

0

提供されたスクリプトは機能します (この jsFiddleに見られるように)。<!DocTypeメタ タグは安全に削除できます。

例えば

<head>
  <!-- Current head content here -->
  <script type="text/javascript">
    (function() {
      var cx = '012476238773441236228:ivxtfsk4-uc';
      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>

</head>

そして、あなたの体の中で、ボックスを表示したい場所:

<gcse:search></gcse:search>​

おそらく、デバッグ ヘルプ用に現在のコードで jsFiddle を作成できますか?

于 2012-08-09T12:51:58.180 に答える