我在我的网站上使用nicescroll jquery插件。我也在我的搜索页面上使用谷歌的自定义搜索。自定义搜索只有一个结果界面,我在<div>
显示搜索结果。
nicescroll以这种方式工作,如果页面需要滚动条,它将显示一个。如果页面不需要滚动条,它将不会显示滚动条。
我在我的母版页中使用脚本标记来调用jquery和nicescrolll库,我在搜索页面中使用脚本标记来加载谷歌的自定义搜索脚本。
问题是在IE中,(因为谷歌的自定义搜索需要一些时间来加载结果)滚动条不会出现(我认为这是因为首先页面不需要滚动条,因为结果搜索还没有显示!但是即使在结果显示之后,IE中仍然没有滚动条。)我注意到如果我调整IE窗口大小然后又回到原来的大小,滚动条会出现。这是我的代码:
//these scripts load in my master page(since I need the scrollbar for my other pages)
<script type="text/javascript" src="/Scripts/jquery-1.7.1.js"></script>
<script type="text/javascript" src="/Scripts/jquery.nicescroll.js"></script>
<script type="text/javascript">
$(window).load(function () {
$("html").niceScroll();
}
);
</script>
//this script loads in my search.aspx page where I want the search results to appear
<script type="text/javascript">
$(document).ready(function () {
(function () {
var cx = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
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);
})();
});
//and here's how I am showing the results
<div id="searchWrapper">
<gcse:searchresults-only></gcse:searchresults-only>
</div>
正如您所看到的,我甚至尝试将nicescroll脚本放在window.load
事件中,因为它将在document.ready
之后发生。但问题仍然存在!!
ps:我的搜索页面在chrome和firefox上工作正常。我只对IE有这个问题。
关于我的问题的任何想法?