我正在一个网站上工作,上面有一些 jquery 滑块,以及其他一些功能。但是,在 IE 中每隔几个页面跳转(并且 IE 仅据我所见)jquery 将不会加载,从而破坏页面。在 IE 中有时不会加载的部分来自 jquery.cycle.all.js 文件。这是我的代码的 javascript 部分。
<script type="text/javascript" src="javascript/modernizr.js"></script>
<script type="text/javascript" src="javascript/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="javascript/jquery.cycle.all.js"></script>
<script type="text/javascript">
$(document).ready(function() {
if (!Modernizr.input.placeholder) {
$('input[placeholder], textarea[placeholder]').each(function(index, elem) {
elem = $(elem);
placeholder = elem.attr('placeholder');
elem_id = elem.attr('id');
elem_name = elem.attr('name');
clone = elem.clone();
clone.hide();
if (elem_id) {
clone.attr({'id': elem_id+'-fake'});
}
if (elem_name) {
clone.attr({'name': elem_name+'-fake'});
}
clone.addClass('fake');
clone.data({'original': $(elem)});
clone.val(placeholder);
clone.focus(function(e) {
e.preventDefault();
$(this).hide();
$(this).data('original').show().focus();
});
elem.blur(function() {
if ($(this).val() == '') {
$(this).hide();
$(this).next().show();
}
});
elem.after(clone);
elem.blur();
});
}
$('#image-slider').cycle({
speed: 1000,
timeout: 1000
});
$('#text-slider').cycle({
speed: 1000,
timeout: 10000
});
$('#ad-1').cycle({
speed: 1000,
timeout: 1000
});
$('#ad-2').cycle({
speed: 1000,
timeout: 1000
});
$('#gallery-slider').cycle({
speed: 2000,
timeout: 2500
});
});
function PopupCenter(pageURL, title, w, h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
</script>
据我所见,占位符和#image-slider 部分每次都有效。#text-slider、#ad-1 和 #ad-2 仅在 IE 中偶尔失败。有人请告诉我我错过了什么,我在这里扯头发。可以在此处找到该站点的链接http://memorysquare.com/testSite/