forumAdict forumAdict - 1 month ago 6
Javascript Question

Ajax to make browser Load

1- OPEN FIREBUG, on the console tab

2- OPEN YOUR GMAIL ACCOUNT,

3- when gmail is loaded, click on one of your label (at the left under the draft box)

4- WITH FIREBUG YOU SEE THAT THE PAGE DOES NOT COMLETLY RELAOD SINCE ALL PREVIOUS ACTION STILL THERE FOR THE CURRENT DOCUMENT, BUT THE BROWSER COMPLETLY ACT LIKE THE PAGE HAVE BEEN RELOADED, stop button browser own loading effect, etc...)

5- !!!!! this is it..!!!!

Does some on have a clue on how site like Gmail can make the browser load on ajax call ( I mean show the loading icon and all, history, etc)

I already know what to check for the history navigation but how in the world they can make the browser to act like this was a simple link that load a complete new page.

from what I see with things like firebug Gmail basically retrieve mail information in JSON and than use some Javascript to render it to the user. But how they make the browser load in the while.

In gmail once it is loaded, obviously they ain't load all the data, from all your folder in background, so when you click on some of your folder and the data is not already loaded they make the browser 'load' like if it were loading a complete new page, while they retrieve the information from their server with some ajax call ( in Firefox you see the browser act like when you click on a normal link, loading icon, stop (x) button activated, and all).

Is it clear?

I came up with some 'ugly' code to achieve my goal that work quite nice in FireFox and IE (sadly it seems to not work in Chrome/WebKit and Opera).

I tell the browser to go to a url that it will not be able to reach before the ajax call end, with window.location=. The browser start to load and than when the ajax call sucess I call window.stop() (window.document.execCommand('Stop') for IE) than innerHTML the ajax data in the document

To me its look ugly and since it not work properly in Chrome/Webkit, this is apparently not the way to go.

Answer
document.getElementById('iframe').src = "http://www.exemple.com/browser_load.html";
Comments