滚动顶部闪烁-Internet Explorer
ScrollTop flicker - Internet Explorer
我的公司要求我调查下一页上的一个问题http://waxy.cloudtelephones.co.uk/departments/#voice当在Internet Explorer中查看时(肯定是IE9,我想它会影响7-10)。
问题如下-当点击页面上的任何主链接时("部分"菜单-语音、连接、云、移动或每个部分中的子菜单-呼叫和线路、托管VoIP、ISD..等),jquery被触发以显示相关部分,在Chrome、FF和Safari中,一切都可以正常工作,然而,在IE中,在运行ScrollTop命令之前,窗口会瞬间闪烁到锚点标记。
下面提供了Javascript代码示例,如有任何帮助,将不胜感激。
//hash control
if(window.location.hash) {
var hash = window.location.hash.substring(1);
var selected = "." + hash;
var parents = [ "voice", "mobile", "cloud-services", "connectivity"];
if ($.inArray(hash, parents) != -1) {
$('html, body').animate({"scrollTop":"0"});
$(selected).show();
$('#buttom-nav ul li#' + hash).addClass('selected');
$(selected + " aside.sub-menu").slideDown('slow');
$(selected + " .child-menu li:first").addClass('selected');
$(selected + " .child-page:first").delay(1000).fadeIn('slow');
};
if ($.inArray(hash, parents) == -1) {
var parent = $(selected).closest('.dptmnts').attr('class').split(' ')[2];
$('html, body').animate({"scrollTop":"0"});
$(selected).closest('.dptmnts').show();
$('.child-menu li#' + hash).addClass('selected');
$('#buttom-nav ul li#' + parent).addClass('selected');
$(selected).siblings('aside.sub-menu').slideDown('slow');
$(selected).fadeIn('slow').delay(1000).fadeIn('slow');
};
};
//hash change control
$(window).bind('hashchange', function () {
var hash = window.location.hash.substring(1);
var selected = "." + hash;
var parents = [ "voice", "mobile", "cloud-services", "connectivity"];
if ($.inArray(hash, parents) != -1) {
$(document).scrollTop(0);
$("aside.sub-menu:visible").slideUp('fast');
$(".child-page:visible").fadeOut('fast');
$(".dptmnts:visible").delay(1000).hide('fast');
$('#buttom-nav ul li').removeClass('selected');
$('.child-menu li').removeClass('selected');
$('.child-menu li#' + hash).addClass('selected');
$(selected).fadeIn('fast');
$('#buttom-nav ul li#' + hash).addClass('selected');
$(selected + " aside.sub-menu").delay(500).slideDown('slow');
$(selected + " .child-menu li:first").addClass('selected');
$(selected + " .child-page:first").delay(500).fadeIn('slow');
};
if ($.inArray(hash, parents) == -1) {
var parent = $(selected).closest('.dptmnts').attr('class').split(' ')[2];
$(document).scrollTop(0);
$(".child-page:visible").fadeOut('fast');
$('.child-menu li').removeClass('selected');
$('.child-menu li#' + hash).addClass('selected');
$(selected).delay(500).fadeIn('slow');
};
});
$( ".page-departments #content a" ).not('.pop-up').click(function(event) {
event.preventDefault()
window.location.hash = this.hash;
$(document).scrollTop(0);
return false;
});
最后一件事-我认为问题可能是两个散列事件(加载和更改)以及所有调用scrollTop的点击函数之间的冲突,但我已经尝试完全删除点击函数,它没有解决问题,而是在Chrome、FF和Safari中出现了相同的"闪烁"!
$(window).bind('hashchange', function (e) {
e.preventDefault();
// rest of your code
阻止hashchange
事件的默认操作
记住还要将e
参数添加到函数中。
相关文章:
- 视频HTML没有'无法在Internet Explorer 11上工作
- Internet Explorer缺少占位符支持,特别是密码字段
- Internet Explorer中的文本换行错误
- 为什么我在Internet Explorer上看不到html元素
- internet explorer 8兼容模式下的Youtube api错误
- 当浏览器控制台未打开时,为什么要求会导致Internet Explorer 9超时
- Internet Explorer 8. Events
- jQuery表单验证适用于Mozilla和Internet Explorer,但不适用于Chrome或Safari
- element.dataset in Internet Explorer
- Facebook FB.init”;访问被拒绝”;在Internet Explorer 11中
- JavaScript不适用于internet explorer和Firefox,但适用于谷歌
- 在Internet Explorer中,向所选内容添加选项不起作用
- 在Internet Explorer中从二进制文件打开PDF
- elementproblem internet explorer
- 我可以使用哪些方法在Internet Explorer中禁用Alt+*X*
- 如何在Internet Explorer中使用javascript设置cookie
- 只有当alert()在带有AJAX的internet explorer中使用时,Javascript才会更新UI
- sharepoint站点的internet explorer中出现Javascript错误
- Internet Explorer重新加载IFrame
- Internet Explorer Internet Failure HTTP Status Codes