Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

History Api: How to tell the browser, that the page is loading?

I've been working with the history api while I loading pages asynchronously via javascript/ jquery. I wondering how it's possible to tell the browser, that the site is loading, so that the browser can show a loading picture (like the spinning wheel in firefox).

Edit:

To be more specific:

If I load a page on my website, the url changes, the new content is shown, but Firefox don't show the spinning wheel as a signal, that the page is loading.

If I open a picture from the timeline in Facebook, the image is loading, the url changes and Firefox shows the spinning wheel to show, that the image is loading in the background.

I want that spinning wheel too!

like image 268
Olli Avatar asked Nov 13 '12 08:11

Olli


1 Answers

I found the answer in these question:

How to have AJAX trigger the browser's loading

var i = $('<iframe>');
console.log(i);
i.appendTo('body');
function start() {
    i[0].contentDocument.open();
    setTimeout(function() {
        stop();
    }, 1000);
}
function stop() {
    i[0].contentDocument.close();
    setTimeout(function() {
        start();
    }, 1000);
}

start();

Source: jsFiddle

The script creates an iframe, which is triggerd by the ajax.start & ajax.stop-event.

like image 199
Olli Avatar answered Nov 15 '22 18:11

Olli