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