views:

408

answers:

2
$(document).ready(function(){
$("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank");

$("a[target!='_blank'][target!='_top']").click(function(){


$("#actualcontent").load($(this).attr("href"));
$("#nav").load('nav.php');

window.location.hash=$(this).attr("href");
        return false;
    });
});

This code works fine, but when you click links, the pages load but they freeze the page until fully loaded. Any idea of a workaround?

This script is embedded at the bottom of the page. It also sometimes reloads the page - which isn't really a problem, but when it's freezing, it can become very frustrating. As well as when you're entering information into a input.

If you ask any questions, I will reply to them pretty quickly. Cheers ;)

Also, this script works with all the links on the initial page, but if I load a new page (via this script), their links just open normally.

How can I work around this? As if I embed this script into every page, it seems to make the page reload continuously. (That could be another error though), cheers!

A: 

what is #actualcontent ? you appear to be attempting to load() entire <html></html> pages into that element?

A better way to do this since often pages have script code that needs to run to assemble its content, is to load the page into a hidden <IFRAME> and on then for the iframe's load event, append the innerHTML of its <BODY> to your element

Scott Evernden
A: 

I had a similar problem with the browser freezing with jquery .ajax() function. If you are developing and testing locally, for some reason it freezes the web browser until the data is retrieved. After uploading my code to a web server it started to work with no problems. I hope this helps, because it took me hours to figure it out for myself. Also make sure async property is set to true (by default it is true).

Matt