$(document).ready(function() {
// Check for hash value in URL
var hash = window.location.hash.substr(1);
var href = $('#menu a, #name a, #contact_us a, #item a, #text a').each(function(){
var href = $(this).attr('href');
if(hash==href.substr(0,href.length-4)){
var toLoad = hash+'.php #pagearea';
$('#pagearea').load(toLoad)
}
});
$('#menu a, #name a, #contact_us a, #item a, #text a').click(function(e){
if($(e.target).is('foo')){
e.preventDefault();
window.location.href = "/current/forum";
return;
}
var toLoad = $(this).attr('href');
$('#pagearea').hide('fast',loadContent);
$('#load').remove();
$('#wrapper').append('<span id="load">LOADING...</span>');
$('#load').fadeIn('normal');
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-4);
function loadContent() {
$('#pagearea').load(toLoad,'',showNewContent())
}
function showNewContent() {
$('#pagearea').show('normal',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
});
});
Which works very well for the menus and other divs around the index. But if I try to follow a hyperlink in #pagearea, it opens a new webpage, rather than putting the link in #pagearea like the rest.
I have tried:
$(function(){
$("#pagearea > a").click(function() {
var link = $(this).attr('href');
$('#pagearea').load(link);
return false;
});
});
and...
$("#pagearea a").bind("click", function() {
var link = $(this).attr("href");
$("#pagearea").load(link);
});
everywhere and every which way I could to no luck. What am I missing here? In a perfect world, the followed links would also apply the hash-url, but at this point if dropping the hash-urls entirely is what it would take to do this then I'm all for it.
Thanks for your time.