Javascript 代码为';与IE不兼容?
嘿,我的一位评论员告诉我,这段代码在IE中不起作用。我一辈子都不知道为什么。无论何时切换选项卡,选项卡的内容都不会更改。同时#holder div的内容是所有选项卡的组合Javascript 代码为';与IE不兼容?,javascript,jquery,tabs,Javascript,Jquery,Tabs,嘿,我的一位评论员告诉我,这段代码在IE中不起作用。我一辈子都不知道为什么。无论何时切换选项卡,选项卡的内容都不会更改。同时#holder div的内容是所有选项卡的组合 有什么想法吗?不是你想要的答案,但如果可以的话,我想调查一下。至少处理这些事情让我的生活轻松多了。这不是你想要的答案,但如果可以的话,我会调查一下。这至少让我的生活更容易处理这些事情。如果没有IE版本和页面来查看到底发生了什么,很难说清楚-但这里有一些最好的猜测: 更改: $(document).ready(function(
有什么想法吗?不是你想要的答案,但如果可以的话,我想调查一下。至少处理这些事情让我的生活轻松多了。这不是你想要的答案,但如果可以的话,我会调查一下。这至少让我的生活更容易处理这些事情。如果没有IE版本和页面来查看到底发生了什么,很难说清楚-但这里有一些最好的猜测: 更改:
$(document).ready(function() {
var url = document.location.toString();
$('.tab').click(function() {
if($(this).is(".active")) {
return;
}
var classy = $(this).attr("class").split(" ").splice(-1);
var innerhtml = $('.content.'+classy).text();
$('#holder').html(innerhtml);
$('.tab').removeClass('active');
$(this).addClass('active');
});
var url = document.location.toString();
if(url.match(/#([a-z])/)) {
//There is a hash, followed by letters in it, therefore the user is targetting a page.
var split = url.split("#").splice(-1);
$('.tab.'+split).click();
}
else {
$('.tab:first').click();
}
});
if($(this).hasClass("active")) {
var innerhtml = $('.content .'+classy).text(); // note the space
致:
更改:
$(document).ready(function() {
var url = document.location.toString();
$('.tab').click(function() {
if($(this).is(".active")) {
return;
}
var classy = $(this).attr("class").split(" ").splice(-1);
var innerhtml = $('.content.'+classy).text();
$('#holder').html(innerhtml);
$('.tab').removeClass('active');
$(this).addClass('active');
});
var url = document.location.toString();
if(url.match(/#([a-z])/)) {
//There is a hash, followed by letters in it, therefore the user is targetting a page.
var split = url.split("#").splice(-1);
$('.tab.'+split).click();
}
else {
$('.tab:first').click();
}
});
if($(this).hasClass("active")) {
var innerhtml = $('.content .'+classy).text(); // note the space
致:
更改:
$(document).ready(function() {
var url = document.location.toString();
$('.tab').click(function() {
if($(this).is(".active")) {
return;
}
var classy = $(this).attr("class").split(" ").splice(-1);
var innerhtml = $('.content.'+classy).text();
$('#holder').html(innerhtml);
$('.tab').removeClass('active');
$(this).addClass('active');
});
var url = document.location.toString();
if(url.match(/#([a-z])/)) {
//There is a hash, followed by letters in it, therefore the user is targetting a page.
var split = url.split("#").splice(-1);
$('.tab.'+split).click();
}
else {
$('.tab:first').click();
}
});
if($(this).hasClass("active")) {
var innerhtml = $('.content .'+classy).text(); // note the space
致:
如果没有IE版本和页面来查看到底发生了什么,很难说清楚-但这里有一些最好的猜测: 更改:
$(document).ready(function() {
var url = document.location.toString();
$('.tab').click(function() {
if($(this).is(".active")) {
return;
}
var classy = $(this).attr("class").split(" ").splice(-1);
var innerhtml = $('.content.'+classy).text();
$('#holder').html(innerhtml);
$('.tab').removeClass('active');
$(this).addClass('active');
});
var url = document.location.toString();
if(url.match(/#([a-z])/)) {
//There is a hash, followed by letters in it, therefore the user is targetting a page.
var split = url.split("#").splice(-1);
$('.tab.'+split).click();
}
else {
$('.tab:first').click();
}
});
if($(this).hasClass("active")) {
var innerhtml = $('.content .'+classy).text(); // note the space
致:
更改:
$(document).ready(function() {
var url = document.location.toString();
$('.tab').click(function() {
if($(this).is(".active")) {
return;
}
var classy = $(this).attr("class").split(" ").splice(-1);
var innerhtml = $('.content.'+classy).text();
$('#holder').html(innerhtml);
$('.tab').removeClass('active');
$(this).addClass('active');
});
var url = document.location.toString();
if(url.match(/#([a-z])/)) {
//There is a hash, followed by letters in it, therefore the user is targetting a page.
var split = url.split("#").splice(-1);
$('.tab.'+split).click();
}
else {
$('.tab:first').click();
}
});
if($(this).hasClass("active")) {
var innerhtml = $('.content .'+classy).text(); // note the space
致:
更改:
$(document).ready(function() {
var url = document.location.toString();
$('.tab').click(function() {
if($(this).is(".active")) {
return;
}
var classy = $(this).attr("class").split(" ").splice(-1);
var innerhtml = $('.content.'+classy).text();
$('#holder').html(innerhtml);
$('.tab').removeClass('active');
$(this).addClass('active');
});
var url = document.location.toString();
if(url.match(/#([a-z])/)) {
//There is a hash, followed by letters in it, therefore the user is targetting a page.
var split = url.split("#").splice(-1);
$('.tab.'+split).click();
}
else {
$('.tab:first').click();
}
});
if($(this).hasClass("active")) {
var innerhtml = $('.content .'+classy).text(); // note the space
致:
我做了Ryan建议的所有更改,除了根据需要在“.content”和句点之间添加空格。没有源代码,他不可能知道 我将.splice(-1)更改为[1],以便选择数组中的第二项,即类名。看起来.splice(-1)在IE和其他浏览器中的行为有所不同 我已经用IE7-8测试了代码,它是有效的 目前的源代码:
var url = document.location.hash;
我做了Ryan建议的所有更改,除了根据需要在“.content”和句点之间添加空格。没有源代码,他不可能知道 我将.splice(-1)更改为[1],以便选择数组中的第二项,即类名。看起来.splice(-1)在IE和其他浏览器中的行为有所不同 我已经用IE7-8测试了代码,它是有效的 目前的源代码:
var url = document.location.hash;
他们有没有说他们使用的是哪个版本的IE?IE6充满了在IE7/8中已经解决的问题。我不知道答案,但我会先在IE8中尝试。如果它在那里工作,那么按F12键启动开发者控制台,然后单击地址栏旁边的断页图标将其置于IE6/7兼容模式。这将重新加载页面,代码导致的任何错误都将出现在开发人员控制台中。如果它仍然有效,只有到那时你才能找到真正的IE6机器。嘿,这仍然不起作用。代码的链接在下面的注释中。非常感谢任何帮助。他们有没有说他们使用的是哪个版本的IE?IE6充满了在IE7/8中已经解决的问题。我不知道答案,但我会先在IE8中尝试。如果它在那里工作,那么按F12键启动开发者控制台,然后单击地址栏旁边的断页图标将其置于IE6/7兼容模式。这将重新加载页面,代码导致的任何错误都将出现在开发人员控制台中。如果它仍然有效,只有到那时你才能找到真正的IE6机器。嘿,这仍然不起作用。代码的链接在下面的注释中。非常感谢您的帮助。不要测试“url.match”,因为哈希标记不会被包括在内-只要看看它是否存在即可。谢谢您的回复,下面是代码的链接:抱歉,等待了-我不得不做一些我得到报酬的工作。。。Manticore似乎已经完成了下面的工作,不要测试“url.match”,因为hashmark不会被包括在内-只要看看它是否存在就可以了。谢谢你的回复,这里是代码链接:抱歉,等待了-我不得不做一些我得到报酬的工作。。。Manticore似乎已经完成了以下工作