我的網站結構簡要概述:jQuery - 爲什麼IE8不喜歡這個功能?
主要索引php通過ajax提供本地存儲的php文件。 (如果這聽起來凌亂,這是因爲它是)
我有,我從AJAX加載的腳本調用主索引文件的函數,它無處不在,工作正常,除了IE瀏覽器。
我不能讓一個有意義的錯誤消息:
Invalid argument. jquery-1.4.2.min.js, line 144 character 219
NB這個問題直接關係到我以前的一個:jQuery $el.position(...) is undefined
jQuery函數(的index.php)
// nav
var $el;
var leftPos;
var newWidth;
var $mainNav = $("#navbar ul");
$mainNav.prepend("<li id='magic-line'></li>");
var $magicLine = $("#magic-line");
function navBar() {
// console.log('navBar start');
function checkActive() {
// console.log('check active');
// Hide magic line if nav bar has no active element
if($('#navbar ul').children('.active').length < 1) {
$magicLine.hide();
//console.log($('#navbar ul').children('.active').length < 1);
//console.log($('#magic-line'));
//console.log('hide');
}
else {
$magicLine.stop().animate({
left: $magicLine.css('left', $(".active a").css('left')),
width: $magicLine.width($(".active a").width())
});
}
}
checkActive();
$magicLine
.width($(".active a").width())
.css("left", $(".active a").position().left)
.data("origLeft", $magicLine.position().left)
.data("origWidth", $(".active a").width());
// $("#navbar ul li a").hover(function() {
// apply hover function to li instead and just just el to it's child
$("#navbar ul li").hover(function() {
// $el = $(this);
$el = $(this).children('a');
// leftPos = $el.position().left;
leftPos = $el.parent().position().left;
newWidth = $el.width();
$magicLine.stop().animate({
left: leftPos,
width: newWidth
}, 600);
}, function() {
if($('#navbar ul').children('.active').length < 1) {
$magicLine.stop();
checkActive();
} else {
$magicLine.stop().animate({
left: $magicLine.data("origLeft"),
//width: $magicLine.data("origWidth")
width: $magicLine.width($(".active a").width())
}, 600);
}
});
}
這是通過簡單地做叫我所有的腳本:
navBar();
但由於某些原因,它在IE瀏覽器造成的問題,我看不出有任何理由,爲什麼它會。
使用Chrome或螢火獲得堆棧跟蹤,看看它失敗 – 2013-03-01 12:46:40
感謝,但是這東西,在Chrome和Firefox沒有報道那麼它只是IE的錯誤。 – martincarlin87 2013-03-01 13:13:52
對不起,考慮到問題在這個過程中忘記了問題的細節。忘了我說的:) – 2013-03-01 13:30:28