I’ve got this code in 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();
});
});
and this code is reloading the div content without reload whole page and adds active class to clicked link.
My question is how to add class active and load properly content if i copy link from browser paste it in to new window?
EDIT: You can use the builtin js window.location.hash to get the value of the hash in the url and do your logic off of that.
hashVal will return with the hash included i.e. : “#hashVal”