I notice that when I browse pages in Twitter. Instead of having some like twitter.com/home.php?var1=2&asjfaj...etc. (the most common way), the link is just Twitter.com/#home or twitter.com/inbox or twitter.com/followers. my guess is, they use sessions variables to pass information across pages/ links. is it a good way to do it? what are the pros and cons of using session or the url query to pass data across pages?
A:
ajax. lot of ajax!
EDIT
this is what I use to keep a history
<script>
function openOption(opened) {
if (!opened)
var selectedTab = document.location.hash;
else
var selectedTab = opened;
if (selectedTab != null && selectedTab.length > 0) {
selectedTab = (selectedTab[0] == '#') ? selectedTab.substring(1, selectedTab.length) : selectedTab;
if ($(selectedTab)) {
toggleLayer_on(selectedTab);
$(selectedTab).focus();
$(selectedTab).scrollTo();
}
}
}
openOption();
</script>
Gabriel Sosa
2009-10-12 22:13:18
+1
A:
They're loaded via AJAX. The #home
etc. in the URL allows bookmarking and browser history - if you go to http://twitter.com/#replies
you get the replies page correctly, as their JavaScript code looks for document.location.hash
's value and loads the right page.
Gmail also does this with the document hash, if you want another example.
ceejayoz
2009-10-12 22:15:50
ok. I get it for the location.hash concept. so, everytime the link is clicked, the javascript will check the location.hash and resolve to the correct URL, right?Another question, is that .. do you think "twitter.com/inbox " (without the archor) is using session? can it also location hash? (I guess not). :)
Murvinlai
2009-10-12 22:38:18
Why would they need sessions or hash for `twitter.com/inbox`? It's just a normal URL. If you're wondering how it's lacking the `.extension` in the URL, though, that's done with URL rewriting - search StackOverflow for `mod_rewrite` and `clean URLs` for help.
ceejayoz
2009-10-13 14:03:20