I want to convert my website into a single page app. This function does the trick:
$(document).ready(function(){
$("body").delegate("a", "click", function(){
var href = $(this).attr("href");
$.get(href,function(data){
var newDoc = document.open("text/html", "replace");
newDoc.write(data);
newDoc.close();
});
return false;
});
});
Assuming I have no redirects other than <a>
tags, it should work fine, right? It feels so wrong and yet so right...