Google自定义搜索在底部创建了一个巨大的空白区域

时间:2012-05-18 06:01:56

标签: javascript google-custom-search

在使用Google自定义搜索(支持iframe)时,它会在底部创建一个巨大的空白区域?我怎样才能避免这个空白。

例如:此网站[http://www.town.togitsu.nagasaki.jp/search/pub/Default.aspx?c_id=2&q=togitsu&cx=000096980916426724425:keok8sbpuem&cof=FORID:10&ie=UTF-8]会在底部创建一个巨大的空白区域。

我检查了来源(http://www.google.com/afsonline/show_afs_search.js),但无法将其删除。

1 个答案:

答案 0 :(得分:0)

将此iframe的height属性更改为1260:

<iframe name="googleSearchFrame" src="http://www.google.com/cse?c_id=2&amp;q=togitsu&amp;cx=000096980916426724425:keok8sbpuem&amp;cof=FORID:10&amp;ie=UTF-8&amp;ad=n9&amp;num=10&amp;rurl=http%3A%2F%2Fwww.town.togitsu.nagasaki.jp%2Fsearch%2Fpub%2FDefault.aspx%3Fc_id%3D2%26q%3Dtogitsu%26cx%3D000096980916426724425%3Akeok8sbpuem%26cof%3DFORID%3A10%26ie%3DUTF-8&amp;siteurl=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F10647487%2Fgoogle-custom-search-create-a-huge-blank-space-at-the-bottom" frameborder="0" width="795" height="1260" marginwidth="0" marginheight="0" hspace="0" vspace="0" allowtransparency="true" scrolling="no"></iframe>

这很可能是由搜索的JavaScript代码动态添加的。如果是这种情况,您需要使用JavaScript动态更改高度:

$(document).ready(function() {
    $('[name="googleSearchFrame"]').attr("height","1260");
});