我在页面上使用jCarousel Lite jQuery plugin,但它似乎在Firefox 3.6中造成严重问题。在该浏览器中,页面会暂时加载,然后所有内容都会消失,除了我正在使用该插件的<li>
个元素之一。
相关网页是here。应用轮播的代码:
<script type="text/javascript">
jQuery(window).load(function() {
jQuery(".loopnetcarousel").jCarouselLite({
btnNext: ".next",
btnPrev: ".prev"
});
});
</script>
(我最初使用的是(document).ready
,但是在看到有人在Firefox 3.6中遇到问题之后用(window).load
替换了它,但这似乎没有改变任何东西。)
更多信息:如果我按照描述更换所有页面内容之前停止页面加载,一切正常,包括轮播。此外,我尝试用另一个脚本替换该轮播脚本,并出现同样的问题。
答案 0 :(得分:3)
看起来问题是loopnet.com属性的加载方式。 loopnet.com脚本使用document.write创建轮播内容。如果查看Firebug中的Net选项卡,您将看到loopnet.com脚本全部加载两次。首先加载页面,然后在运行轮播脚本时再次加载。第二次在Firefox中运行document.write只清除整个页面。一个简单的解决方法是在设置轮播代码之前删除脚本标记。示例jsFiddle:http://jsfiddle.net/fqFH7/7/
$(function() {
//remove the scripts so that they are not executed again by the carousel code
jQuery(".loopnetcarousel script").remove();
jQuery(".loopnetcarousel").jCarouselLite({
btnNext: ".next",
btnPrev: ".prev"
});
});
尝试在jsFiddle中注释掉remove()行,您将看到与您的网站相同的问题。
答案 1 :(得分:0)
在您引用的页面上,以下资源需要永久加载:
答案 2 :(得分:0)
在插件的网站上:
根据流行的请求,jCarouselLite已更新为支持jquery 1.2.x版本。转到下载页面并下载1.0.1版以享受jquery 1.2.x支持。由于Firefox 3在$(document).ready()函数中存在一些问题,因此如果您遇到任何问题,请尝试使用$(window).load()。希望Firefox或jQuery的未来版本能够解决这个问题。
取自:http://www.gmarwaha.com/blog/2007/08/09/jcarousel-lite-a-jquery-plugin/