Javascript 没有jQuery在IE版本6-11中工作
我似乎有一个问题,我的jQuery函数似乎不能在所有IE版本中工作,但是这些函数在Chrome、Safari和Firefox中似乎工作得很好 它甚至在IE11/Windows10中都不起作用 我有什么遗漏吗 谢谢你的帮助Javascript 没有jQuery在IE版本6-11中工作,javascript,jquery,internet-explorer,browser,cross-browser,Javascript,Jquery,Internet Explorer,Browser,Cross Browser,我似乎有一个问题,我的jQuery函数似乎不能在所有IE版本中工作,但是这些函数在Chrome、Safari和Firefox中似乎工作得很好 它甚至在IE11/Windows10中都不起作用 我有什么遗漏吗 谢谢你的帮助 (function($) { 'use strict'; $(document).ready(function() { (function(){ if (!/portfolio-item/.test(window.location.href)) r
(function($) {
'use strict';
$(document).ready(function() {
(function(){
if (!/portfolio-item/.test(window.location.href)) return;
var i;
var bigwrap = document.querySelector('.page-header .portfolio-entry-img').parentNode;
var bigimages = {};
var products = document.querySelectorAll('.product-thumbnail-wrap img');
var title = document.querySelector('.product-title');
var code = document.querySelector('.product-code');
var trays_tmp = document.querySelectorAll('.tray-reference [data-tray]');
var trays = {};
var wraps_tmp = document.querySelectorAll('.tray-wrap');
var wraps = {};
var active = {};
active.bigimage = bigwrap.firstElementChild;
if(active.bigimage) bigimages[active.bigimage.src] = active.bigimage;
for(i in Object.keys(trays_tmp)) {
if (trays_tmp.hasOwnProperty(i)) {
trays[trays_tmp[i].dataset.tray] = trays_tmp[i];
if(/tray-active/.test(trays_tmp[i].className)) active.tray = trays_tmp[i].dataset.tray;
}
}
for(i in Object.keys(wraps_tmp)) {
if (wraps_tmp.hasOwnProperty(i)) {
var table = wraps_tmp[i].dataset.table;
wraps[table] = wraps_tmp[i];
if(wraps_tmp[i].style.display === '') active.wrap = wraps_tmp[i];
}
}
for (i in Object.keys(products)) {
if (products.hasOwnProperty(i)) {
if (/product-thumb-active/.test(products[i].className)) active.product = products[i];
if (products[i].dataset.big && !bigwrap.querySelector('[src="' + products[i].dataset.big + '"]') && active.bigimage) {
var bigimg = active.bigimage.cloneNode();
bigimg.src = products[i].dataset.big;
bigimg.style.display = 'none';
bigwrap.appendChild(bigimg);
bigimages[products[i].dataset.big] = bigimg;
}
products[i].addEventListener('click', function() {
if (active.product) active.product.className = active.product.className.replace(/\s*product-thumb-active/, '');
this.className += ' product-thumb-active';
active.product = this;
if (active.tray) trays[active.tray].className = trays[active.tray].className.replace(/\s*tray-active/, '');
active.tray = this.dataset.tray;
if (active.tray){
if (!trays[active.tray]) active.tray = undefined;
else trays[active.tray].className += ' tray-active';
}
console.log(active.tray, trays[active.tray]);
if ((active.tray && active.wrap !== active.tray[0]) || !active.tray) {
if (active.wrap) active.wrap.style.display = 'none';
if (!active.tray) active.wrap = wraps.None;
else active.wrap = wraps[active.tray[0]];
if (!active.wrap) active.wrap = wraps.None;
active.wrap.style.display = '';
}
title.textContent = this.getAttribute('title');
code.textContent = this.getAttribute('code');
if (active.bigimage) active.bigimage.style.display = 'none';
active.bigimage = bigimages[this.dataset.big];
$(active.bigimage).fadeIn('fast');
});
}
}
})();
$(".nav-toggle").click(function() {
$(this).toggleClass("active");
$(".overlay-boxify").toggleClass("open");
$("#site-navigation-wrap").toggleClass("menuActive");
$(".fixed-logo").toggleClass("logoActive");
$("#site-social-wrap").toggleClass("socialActive");
});
$(".overlay ul li a").click(function() {
$(".nav-toggle").toggleClass("active");
$(".overlay-boxify").toggleClass("open");
$("#site-navigation-wrap").toggleClass("menuActive");
$(".fixed-logo").toggleClass("logoActive");
});
$(".overlay").click(function() {
$(".nav-toggle").toggleClass("active");
$(".overlay-boxify").toggleClass("open");
$("#site-navigation-wrap").toggleClass("menuActive");
$(".fixed-logo").toggleClass("logoActive");
});
$('.single-question').click(function() {
$('.tray-reference').toggle();
});
/***************** Header BG Scroll ******************/
var pastWaypoint = false;
$(window).scroll(function() {
if ($(window).scrollTop() > 580 && !pastWaypoint) {
$('.fixed-logo').show();
$(".fixed-header").addClass("hasBg header-sml");
$("#site-navigation-wrap").show();
console.log('d');
pastWaypoint = true;
} else if ($(window).scrollTop() <= 580 && pastWaypoint) {
$('.fixed-logo').hide();
console.log('f');
$(".fixed-header").removeClass("hasBg header-sml");
pastWaypoint = false;
}
});
$('.menu-item a[href^="#"]').on('click', function(e) {
e.preventDefault();
var target = this.hash;
var $target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 900, 'swing', function() {
window.location.hash = target;
});
});
$("img").bind("contextmenu", function(e) {
return false;
});
$("div.desc").hide();
$("input[name$='requestbrochure']").change(function() {
$("div.desc").hide();
$("#" + this.value).show();
}).filter(function() {
return this.checked;
}).change();
$(".resource-tabs-menu a").click(function(event) {
event.preventDefault();
$(this).parent().addClass("resource-current");
$(this).parent().siblings().removeClass("resource-current");
var tab = $(this).attr("href");
$(".resource-tab-content").not(tab).css("display", "none");
$(tab).fadeIn();
});
$('.portfolio-dropdown-content').show();
$('#portfolio-dropdown-menu').click(function() {
$('.portfolio-dropdown-content').slideToggle("fast");
$('#portfolio-dropdown-icon').toggleClass("portfolio-dropdown-selected");
});
$('.request-brochure-button').click(function() {
$('.request-brochure-content').slideToggle("fast");
$('.request-brochure-button').toggleClass("request-brochure-button-active");
});
// Main menu superfish
$('ul.sf-menu').superfish({
delay: 200,
animation: {
opacity: 'show',
height: 'show'
},
speed: 'fast',
cssArrows: false,
disableHI: true
});
// Mobile Menu
$('#navigation-toggle').sidr({
name: 'sidr-main',
source: '#sidr-close, #site-navigation, #mobile-search',
side: 'left'
});
$('.sidr-class-toggle-sidr-close').click(function() {
$.sidr('close', 'sidr-main');
return false;
});
// Close the menu on window change
$(window).resize(function() {
$.sidr('close', 'sidr-main');
});
$("#featuresSlider").flickity({
cellAlign: "left",
contain: true,
prevNextButtons: false
});
$("#showcaseSlider").flickity({
cellAlign: "left",
contain: true,
prevNextButtons: false,
imagesLoaded: true
});
$(".youtube-media").on("click", function(e) {
var t = $(window).width();
if (t <= 768) {
return
}
$.fancybox({
href: this.href,
padding: 4,
type: "iframe",
href: this.href.replace(new RegExp("watch\\?v=", "i"), "v/")
});
return false;
});
$("a.single_image").fancybox({
padding: 4
});
$(".nav-toggle").click(function() {
$(this).toggleClass("active");
$(".overlay-boxify").toggleClass("open")
});
$(".overlay ul li a").click(function() {
$(".nav-toggle").toggleClass("active");
$(".overlay-boxify").toggleClass("open")
});
$(".overlay").click(function() {
$(".nav-toggle").toggleClass("active");
$(".overlay-boxify").toggleClass("open")
});
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top - 125
}, 1000);
return false;
}
}
});
}); // End doc ready
$(window).load(function() {
// Homepage FlexSlider
$('#homepage-slider').flexslider({
animation: 'slide',
slideshow: true,
smoothHeight: true,
controlNav: false,
directionNav: true,
prevText: '<span class="fa fa-angle-left"></span>',
nextText: '<span class="fa fa-angle-right"></span>',
controlsContainer: ".flexslider-container"
});
// Post FlexSlider
$('div.post-slider').flexslider({
animation: 'slide',
slideshow: true,
smoothHeight: true,
controlNav: false,
directionNav: true,
prevText: '<span class="fa fa-angle-left"></span>',
nextText: '<span class="fa fa-angle-right"></span>',
controlsContainer: ".flexslider-container"
});
}); // End on window load
})(jQuery);
(函数($){
"严格使用",;
$(文档).ready(函数(){
(功能(){
if(!/portfolio item/.test(window.location.href))返回;
var i;
var bigwrap=document.querySelector('.page header.portfolio entry img').parentNode;
var bigimages={};
var products=document.querySelectorAll('.product-thumbnail-wrap-img');
var title=document.querySelector(“.product title”);
var代码=document.querySelector(“.product code”);
var trays_tmp=document.queryselectoral('.tray reference[datatray]');
var={};
var wrapps_tmp=document.querySelectorAll('.tray wrapp');
var={};
var active={};
active.bigimage=bigwrap.firstElementChild;
如果(active.bigimage)bigimages[active.bigimage.src]=active.bigimage;
用于(对象键中的i(托盘\u tmp)){
如果(tmp.hasOwnProperty(i)){
托盘[trays_tmp[i].dataset.tray]=trays_tmp[i];
if(/tray active/.test(trails\u tmp[i].className))active.tray=trails\u tmp[i].dataset.tray;
}
}
对于(对象中的i.key(wrapps\u tmp)){
如果(wraps_tmp.hasOwnProperty(i)){
var table=wrapps\u tmp[i].dataset.table;
wrapps[表]=wrapps_tmp[i];
如果(wrap_tmp[i].style.display=='')处于活动状态。wrap=wrap_tmp[i];
}
}
用于(对象中的i键(产品)){
if(products.hasOwnProperty(i)){
if(/product thumb active/.test(products[i].className))active.product=products[i];
if(products[i].dataset.big&&!bigwrap.querySelector('[src=“'+products[i].dataset.big+']”)&&active.bigimage){
var bigimg=active.bigimage.cloneNode();
bigimg.src=products[i].dataset.big;
bigimg.style.display='none';
appendChild(bigimg);
bigimages[products[i].dataset.big]=bigimg;
}
产品[i].addEventListener('click',函数(){
如果(active.product)active.product.className=active.product.className.replace(/\s*product-thumb-active/,“”);
this.className+=“产品拇指激活”;
active.product=this;
if(active.tray)托盘[active.tray].className=托盘[active.tray].className.replace(/\s*托盘活动/,'');
active.tray=this.dataset.tray;
如果(活动托盘){
如果(!托盘[active.tray])active.tray=未定义;
else托盘[active.tray].className+='tray active';
}
console.log(active.tray,托盘[active.tray]);
if((active.tray&&active.wrap!==active.tray[0])| |!active.tray){
如果(active.wrap)active.wrap.style.display='none';
如果(!active.tray)active.wrap=wrapps.None;
else active.wrap=包装[active.tray[0];
如果(!active.wrap)active.wrap=wrapps.None;
active.wrap.style.display='';
}
title.textContent=this.getAttribute('title');
code.textContent=this.getAttribute('code');
如果(active.bigimage)active.bigimage.style.display='none';
active.bigimage=bigimages[this.dataset.big];
$(active.bigimage).fadeIn('fast');
});
}
}
})();
$(“.nav toggle”)。单击(函数(){
$(此).toggleClass(“活动”);
$(“.overlay-boxify”).toggleClass(“打开”);
$(“#站点导航包装”).toggleClass(“menuActive”);
$(“.fixed logo”).toggleClass(“logoActive”);
$(“#站点社交包装”).toggleClass(“社交活动”);
});
$(“.ul li a”)。单击(函数(){
$(“.nav toggle”).toggleClass(“活动”);
$(“.overlay-boxify”).toggleClass(“打开”);
$(“#站点导航包装”).toggleClass(“menuActive”);
$(“.fixed logo”).toggleClass(“logoActive”);
});
$(“.overlay”)。单击(函数(){
$(“.nav toggle”).toggleClass(“活动”);
$(“.overlay-boxify”).toggleClass(“打开”);
$(“#站点导航包装”).toggleClass(“menuActive”);
$(“.fixed logo”).toggleClass(“logoActive”);
});
$('.single question')。单击(函数(){
$('.tray reference').toggle();
});
/*****************标题背景卷轴******************/
var pastWaypoint=假;
$(窗口)。滚动(函数(){
如果($(窗口).scrollTop()>580&&!pastWaypoint){
$('.fixed logo').show();
$(“.fixed header”).addClass(“hasBg header sml”);
$(“#站点导航包装”).show();
console.log('d');
pastWaypoint=真;
}else if($(window).scrollTop()您是从本地计算机上的文件(不是http或https URL)运行的吗?IE将在默认情况下禁用文件上的JavaScript://通常在页面底部有一个选项来启用它。您可以尝试if(typeof jQuery='undefined'){alert('no jQuery');}
你能告诉我你使用的是哪个版本的jQuery吗?据我所知,2.x不适用于IE9或更低版本?PeterS在你的代码中的任何地方,编辑:从jQuery文档jQuery 2.x与jQuery 1.x具有相同的API,但不支持InternetExplorer 6、7或8。
在你的IE11中,是否启用了JavaScript?@PeterS抱歉没有不行,这是干什么用的