Moderator |
|
Ik gebruik jQuery en heb de onderstaande javascript code (voor gebruik zie https://github.com/browserstate/history.js/):
var currentUrl = '';
function historyjs() {
var type = 'url';
var History = window.History, State = History.getState(), $log = $('#log');
currentUrl = location.pathname;
$("a:not(.fancybox):not([target=_blank]").on('click',function(event) {
event.preventDefault();
var myURLHandler = function(url){
if (type == 'url') {
$.ajax({
url: url
}).done(function(html) {
$('div#ajax-container').html(html);
init();
});
}
};
History.Adapter.bind(window,'statechange',function() {
if (currentUrl != location.pathname) {
var State = History.getState();
myURLHandler(State.url);
currentUrl = location.pathname;
}
});
History.pushState(null, null, $(this).attr('href'));
});
}
var currentUrl = ''; function historyjs() { var type = 'url'; var History = window.History, State = History.getState(), $log = $('#log'); currentUrl = location.pathname; $("a:not(.fancybox):not([target=_blank]").on('click',function(event) { event.preventDefault(); var myURLHandler = function(url){ if (type == 'url') { $.ajax({ url: url }).done(function(html) { $('div#ajax-container').html(html); init(); }); } }; History.Adapter.bind(window,'statechange',function() { if (currentUrl != location.pathname) { var State = History.getState(); myURLHandler(State.url); currentUrl = location.pathname; } }); History.pushState(null, null, $(this).attr('href')); }); }
Deze code werkt in principe goed, en er wordt dus een javascrtip ajax uitgevoerd. Als ik na de ajax-call in chrome kijk (in de bron), dan zie je de hele html. Maar doe ik dit in firefox dan zie ik alleen de source van de ajax request.
Weet iemand hoe ik dit kan fixen?
|