hey guys, I'm not sure if it can be done or not but i'm just curious.
this is my code and I was wondering if it could work theoretically...
//------------------------------------------------------------------
// Menu links
//------------------------------------------------------------------
var newHash = "",
uri = "",
$content = $("#main-content"),
content = '#main-content',
$wrap = $("#wrap"),
baseHeight = 0,
$el;
$wrap.height($wrap.height());
baseHeight = $wrap.height() - $content.height();
$("nav a").live('click', function(){
window.location.hash = $(this).attr("id");
url = $(this).attr("href");
uri = windows.location.hash;
return false;
});
/*$("nav").delegate("a", "click", function() {
window.location.hash = $(this).attr("href");
console.log(window.location.hash);
return false;
});*/
$(window).bind('hashchange', function(){
//window.location.hash = $(this).attr("href");
//newHash = window.location.hash.substring(1);
u = uri.substring(1);
console.log(u);
if (window.location.hash = u) {
$wrap.find("#main-content").fadeOut(200, function() {
$wrap.load(u + " #main-content", function() {
$content.fadeIn(function() {
$wrap.animate({
height: baseHeight + $content.height() + "px"
}, 500);
});
});
});
}
});
$(window).trigger('hashchange');
Current behaviors:
-- when I load www.abc.com/ the URI turns into www.abc.com/# automatically
-- when I click on a menu link it turns the URI to www.abc.com/#!/files/2
(where 2 is the ID of the user and !/files/2 is the id of the link)
-- when the click is invoke it quickly then turn the URI to www.abc.com/file.php# which will now just load the file directly from the server without the ajax effect of loading in content from the page rather than going to a direct link.
I have at one point successfully gotten the link to show as:
http://www.abc.com/#!/file/2 and load content from file.php but with that success I wasn't able to trick the browser into seeing the URI for what it is and load content from file.php based off the URI on a page refresh (for bookmarking reasons)
As far as I know triggers a change of the URL in the browser (except the hashchanges) a load of a new page (in this case a reload). Therefore it should not be possible to show "file.php" in the status bar when #!/file/2 is called...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.