2014-02-06 1 views
0

저는 새로운 자바 스크립트입니다. 나는 다른 뷰에서로드하는 .load 스크립트를 만들 수 있었다 (많은 도움을 줌). 작동하지만 사용자가 www.mydomain.com/#view3과 같은 URL을 사용할 때 스크립트가 적절한보기로로드되도록하는 방법을 모르겠다.html5 history api fallback?

이 기존의 문제 외에도 현재의 현재 위치를 바꾸고 싶습니다. html5 히스토리 API를 사용하여 스크립트를로드하고 클라이언트 브라우저가이를 지원하지 않을 때 이전 스크립트로 폴백하십시오. 브라우저가 히스토리 API를 지원하는지, 대체 방식을 만드는 방법이 아닌지 어떻게 알 수 있습니까? 나는 modernizr이 fallbacks를위한 CSS 클래스를 지원한다는 것을 알고 있습니다. 같은 lib에 javascript에 lib가 존재합니까?

나는 그 많은 것을 알고있다. 메신저는 현재의 자신을 읽기하지만 메신저는 좀 가압 : -/

이 내 corrent 코드 : 불행하게도 나는 다른보기를로드의 문제에 대단히 도움이되지 수 음

$(document).ready(function() { 
    $(".con").load("views/startseite.php", function() { 
     $(".scroll").jScrollPane({mouseWheelSpeed:20});$(".jspDrag").hide();$(".jspScrollable").mouseenter(function(){$(this).find(".jspDrag").stop(!0,!0).fadeIn()});$(".jspScrollable").mouseleave(function(){$(this).find(".jspDrag").stop(!0,!0).fadeOut()}) 
    }); 
    $("nav a").click(function (a) { 
     a.preventDefault(); 
     a = $(this).attr("href").split("/").pop().split(".").shift(); 
     $(".con").hide().load("views/" + a + ".php", function() { 
      $(".con").fadeIn("fast", 
       function() { 
        $(".scroll").jScrollPane({mouseWheelSpeed:20});$(".jspDrag").hide();$(".jspScrollable").mouseenter(function(){$(this).find(".jspDrag").stop(!0,!0).fadeIn("slow")});$(".jspScrollable").mouseleave(function(){$(this).find(".jspDrag").stop(!0,!0).fadeOut("slow")})}) 
     }); 
     document.title = "My-Domain.com | " + (a.substr(0, 1).toUpperCase() + a.substr(1)); 
     location.hash = a; 
     return !1 
    }) 
    $(document).on('submit', 'form.ajax', function (e) { 
     e.preventDefault(); 
     var that = $(this), 
      url = that.attr('action'), 
      type = that.attr('method'), 
      data = {}; 
     that.find('[name]').each(function (index, value) { 
      var that = $(this), 
       name = that.attr('name'), 
       value = that.val(); 
      data[name] = value 
     }); 
     $.ajax({ 
      url: url, 
      type: type, 
      data: data, 
      success: function() { 
       $(".flipbox").flippy({ 
        color_target: "", 
        duration: "500", 
        verso: "Anything!", 
        onFinish: function() { 
         $("#no-color").css("background-color", "transparent"); 
        } 
       }); 
      } 
     }); 
    }); 
    $(document).on('submit', 'form.lebenslauf', function (e) { 
     e.preventDefault(); 
     var $this = $(this); 
     $.ajax({ 
      url: './secure/secure.php', 
      type: 'post', 
      data: { 
       code: $('input[name=bewerbung]').val() 
      }, 
      success: function (resp) { 
       if (resp.substr(0, 5) == "Error") { 
        $('.error').html(resp); 
       } else { 
        $('.flipbox').flippy({ 
         duration: "500", 
         verso: resp, 
         onFinish: function() { 
          $(".flipbox").css("background-color", "transparent"); 
         } 
        }); 
       } 
      } 
     }); 
    }); 
}); 

답변

0

,하지만 난 질문의 두 번째 부분에 대한 통찰력을 제공 할 수 있다고 생각합니다. 그것은 간단한 사전 구축 된 기능과 모든 크로스 브라우저 지원이 장면 뒤에 처리를 제공 https://github.com/browserstate/history.js/

: 당신이 history.js으로 처리 할 수 ​​있습니다 찾고있는 browserstate 기능의 대부분

. html5 히스토리 API를 사용할 수없는 경우 자동으로 대신 해시가 사용됩니다.

여러분이 찾고 계신 도서관, 행운이 있기를 바랍니다.