I am trying to make a navigation bar on the left.
| 1 |
| 2 |
| 3 |
<a href="???" id="1"></a>
<a href="???" id="2"></a>
<a href="???" id="3"></a>
I was wondering how facebook does their left navigational bar because when you click Messages on their bar, it turns into www.facebook.com?sk=inbox.
How do you change ur main div changing your url? Do you put
<a href="?sk=inbox>
but then I was wondering what the action was that changes the div?
Would I have to use $_Request['sk']?
Thanks
I have done something similar to this before:
I had a class called navigation and in my main nav ul
I had the following snippet:
foreach($aAllPages as $key => $value){
$sOutput .= '<li><a href="index.php?pageID='.$key.'">'.$value.'</a></li>'."\n";
}
After I have started the function I set the following:
$pageManager = new PageManager();
$aAllPages = $pageManager->getAllPages();
The page manager was the model name that had a function called getAllPages that processed the specific data from the DB
If I understand you correctly, I think you are referring to how Facebook modifies the URL of the page while making an AJAX call to populate the main div of the page with the new content. If you notice in IE the URL will look like
http://www.facebook.com/#!/?sk=inbox
instead of
http://www.facebook.com/?sk=inbox
Facebook is taking advantage of HTML5 features for modifying the history state (https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history).
This SO post (http://stackoverflow.com/questions/5527617/using-html5-pushstate-in-ie9) points to a history plugin that will take advantage of the new HTML5 features as well as fall back gracefully to older browsers with hashchange functionality.
精彩评论