【发布时间】:2012-02-25 06:57:50
【问题描述】:
我在 jQuery 中有这段代码:
$(document).ready(function() {
// sprawdzanie wartości url
var hash = window.location.hash.substr(1);
var href = $('.seeker .left ul li a').each(function(){
var href = $(this).attr('href');
if(hash==href.substr(4,href.length-8)){
var toLoad = hash+'.htp';
$('#loader').load(toLoad)
}
});
$('.seeker .left ul li a').click(function(){
var toLoad = $(this).attr('href');
$('#loader').hide('fast',loadContent);
$('#load').remove();
$('#loader').append('<span id="load"><img src="img/loader.gif" alt="Ładuję..."</span>');
$('#load').fadeIn('fast');
window.location.hash = $(this).attr('href').substr(4,$(this).attr('href').length-8);
function loadContent() {
$('#loader').load(toLoad,'',showNewContent())
}
function showNewContent() {
$('#loader').show('fast',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('fast');
}
return false;
});
$(function() {
//dodawanie klasy aktywnej do kliknietego linku
$('.seeker .left ul li a').click(function() {
$('.seeker .left ul li a').removeClass('active');
$(this).addClass('active');
return true;
}).filter(':first').click();
});
});
并且此代码正在重新加载 div 内容而不重新加载整个页面并将活动类添加到单击的链接。 我的问题是如果我从浏览器复制链接粘贴到新窗口,如何添加活动类并正确加载内容?
【问题讨论】:
标签: jquery url hyperlink load paste