2011-01-28 3 views
0

안녕하세요 여러분, 잘 할 수 있는지 모르겠지만 그냥 궁금합니다.attr ('id')와 hashchange하지만 jquery를 사용하여 attr ('href')의 콘텐츠를로드하십시오.

이 내 코드이며 이론적 일 수 있는지 궁금 해서요 ...

//------------------------------------------------------------------ 
// 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'); 

현재 행동 :
- 나는 URI가 www.abc로 변신 www.abc.com/로드 .COM/# 자동
! - 나는 그것이 www.abc.com/#!/files/2하기 위해 URI를 회전 링크 메뉴를 클릭하면
(2는 사용자와 의 ID입니다/파일/2은 링크의 ID입니다.
- 클릭이 신속하게 호출되면 URI를 www.abc.com/file.php# 으로 바꿉니다. 이제는 페이지에서 내용을로드하는 아약스 효과없이 서버에서 직접 파일을로드합니다. 직접 링크로 이동합니다. 나는 그것이 무엇인지에 대한 URI를보고으로 브라우저를 속일 수 없었다 file.php에서하지만 성공

http://www.abc.com/#!/file/2 및로드 내용 :

나는 한 지점에서 성공적으로 표시 할 수있는 링크를 입수했습니다 페이지 새로 고침에 대한 URI를 기반으로 file.php의 내용을로드하십시오 (북마크 이유로)

답변

0

내가 아는 한 브라우저에서 URL의 변경 (hashchanges 제외)이 발생합니다. 새 페이지의로드 이 경우 재로드). 따라서 #!/file/2가 호출 될 때 상태 표시 줄에 "file.php"를 표시해서는 안됩니다 ...

관련 문제