4

In order to show you what I want to do you just have to visit gmail. When you click on the inbox, the url refreshes to this ?tab=mm#inbox and the only part of the page that refreshes is the big part where your e-mails are which google calls div.l.m . How is that possible? Are they using cache a lot or they are using a javascript command I'm not aware of?

What I want to do is, I have a page with two different tabs.

<div id="navcontainer">
<ul id="navlist">
<li id="active"><a href="#" id="current">Products</a></li>
<li><a id="prreq" onclick="show()" >Requests</a></li>

</ul>
</div>
<div class="container"></div>

When users go on eg. cart.php they are going to the first tab. When users click on the second tab a js function is triggered which calls the file cart.php?rq=r and the results are shown in the container div. (I know that at the moment I have post)

function show(){
var prstr= ".container"; 
var data= {
    rq: "r"
};
$.ajax({
    type: 'POST',
    url: "cart.php",
    data: data,
    success: function(data1)
    {

        $(prstr).html(data1);

    }
});

}

What I want is when the user refreshes the page to still be in the cart.php?rq=r and not having to click on the tab again. I'd appreciate any help. if you need any more information please let me know Thank you in advance.

viper
  • 539
  • 1
  • 4
  • 16

1 Answers1

3

They are simply accessing the hash component of the url via location.hash. When the hash changes, they must have some logic that determines which part of the page to refresh.

Chris Laplante
  • 29,338
  • 17
  • 103
  • 134
  • 1
    Thank you very much :) Thanks to your post I found this one http://stackoverflow.com/questions/570276/changing-location-hash-with-jquery-ui-tabs I'll accept the answer as soon as the 10 mins pass :) – viper Jul 11 '11 at 22:24
  • 1
    For those that are interested there is also this http://spoiledmilk.dk/blog/html5-changing-the-browser-url-without-refreshing-page . Facebook uses this way for FF4, chrome, safari and hashing for IE – viper Jul 12 '11 at 12:33