0
我有了这个代码jQuery中:的jQuery - 添加活跃链接URL是否被粘贴到浏览器窗口
$(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内容不重新加载整个页面,并增加了活动类来点击链接。 我的问题是如何添加类活动并加载正确的内容,如果我从浏览器复制链接粘贴到新窗口?
如果链接http://mysite.com/#sth它调用锚“INC/sth.htp”如果我将此链接粘贴到浏览器,或者我将此链接发送给某人,我想将活动类添加到此锚点并加载子网站的内容。 – arclite 2012-02-03 08:23:33
我不明白你在说什么:)抱歉,但我在jQ和js太蹩脚 – arclite 2012-02-06 14:45:42