我有一个加载内部链接的功能。该功能工作正常,除了一件事。当您单击链接时,内容宽度会更改,变得更小。我不知道为什么。
{
$(function() {
$(".home li.home").removeClass("home").addClass("current_page_item");
$("#column-warp").append("<img src='/images/ajax-loader.gif' id='ajax-loader'>");
var $mainContent = $("#content"),
URL ='',
siteURL = "http://" + top.location.host.toString(),
$internalLinks = $('a[href^="' + siteURL + '"]'),
hash = window.location.hash,
$ajaxSpinner = $("#ajax-loader"),
$el, $allLinks = $("a");
if (hash){
$ajaxSpinner.fadeIn();
$mainContent.animate({ opacity: "0.1" });
$(".current_page_item").removeClass("current_page_item");
$('a[href="' + hash + '"]').addClass("current_link").parent().addClass("current_page_item");
hash = hash.substring(1);
URL = hash + ".entry-content";
$mainContent.load(URL, function(){
$ajaxSpinner.fadeOut();
$mainContent.animate({ opacity: "1" });
});
}
$internalLinks.each(function () {
$(this).attr("href", "#" + this.pathname);
}).click(function() {
$ajaxSpinner.fadeIn();
$mainContent.animate({ opacity: "0.1" });
$el = $(this);
$(".current_page_item").removeClass("current_page_item");
$allLinks.removeClass("current_link");
URL = $el.attr("href").substring(1);
URL = URL + " #content";
$mainContent.load(URL,function(){
$el.addClass("current_link").parent().addClass("current_page_item");
$ajaxSpinner.fadeOut();
$mainContent.animate({ opacity: "1" });
});
});
});
})(jQuery);