2014-10-19 4 views
1

다른 사람이 개발 한 웹 사이트를보고 있는데 뒤로 버튼이 올바르게 작동하지 않는 문제를 해결하려고합니다. . 이 코드는 제 코드가 아니기 때문에 문제 해결의 우선 순위를 정할 수있는 최적의 위치를 ​​정확히 알 수는 없습니다.뒤로 버튼을 클릭하면 현재 동일한 페이지로 이동합니다.

나는 이것을 빨리 알아 내려고하고있다. 내 질문은 다음과 같다. 이것을 일으킬 수있는 공통점은 무엇인가? 범인이 될 확률이 높은 영역은 무엇입니까?

다음은 작동중인 버그입니다. 예제 포트폴리오 항목 중 하나를 클릭하고 브라우저의 자체 뒤로 버튼을 사용하려고 시도하면 동일한 페이지로 돌아갑니다. 이것은 Angular에서 라우팅의 문제라고 생각하지만 확실히 알지 못합니다. 어떤 아이디어?

+0

두 개 이상의 문제가 있습니다. 예를 들어 뒤로 버튼을 사용하면 처음에는 이전 페이지로 돌아 오지만 탐색 항목은 다른 페이지에 대해 여전히 강조 표시됩니다. 이 시점에서 다시 버튼을 사용하면 설명 된 것처럼 동일한 페이지에 머무르게됩니다. –

+0

뭔가가 리디렉션 중이거나 새 페이지를 두 번 설정하는 것처럼 보입니다. 뒤로 버튼을 클릭 한 채로 있으면 전체 기록을 볼 수 있습니다. – robbrit

+0

멋진 웹 사이트이지만로드하는 데 몇 시간이 걸릴 것입니다. – DividedByZero

답변

2

, 당신은 모든하는 HREF 예 변화에 대한 HTML 에서 # 대신 #route_name의/ROUTE_NAME을 지적해야한다 뒤로 버튼 문제를 해결하려면 :

<a href="#about" .... </a> 

는 사람 :

<a href="#/about" ....  </a> 

나는 귀하의 사이트에 솔루션을 시험하고 다시 버튼을 마법처럼 일했다.

+0

내가 이것을 추가하고 제안 된 변경을하자마자, 모든 것이 작동했다 : ''$ ('[ng-app]') on ('클릭', 'a', function() { window.location .href = $ (this) .attr ('href'); });''' –

1

각도에 대해서는 잘 모릅니다 만,이 문제는 compiled.min.js 파일의 다음 코드 때문에 발생할 수 있습니다. 이 코드 조각의 마지막 4-5 줄은 중요하므로이 문제를 일으킬 수 있습니다. 그것에서 살펴보고 아마 당신은 그것을 알아낼 수 :

angular.module("Site", ['ngSanitize']).config(function ($locationProvider, $routeProvider, $httpProvider) { 

    $httpProvider.defaults.useXDomain = !0, delete $httpProvider.defaults.headers.common["X-Requested-With"], $locationProvider.html5Mode(false); 
    $httpProvider.responseInterceptors.push(function ($q, $location, $rootScope) { 
     return function (promise) { 
      //start spinner 
      /* $rootScope.element = $('.container') 
      $rootScope.element.css('visibility', 'hidden'); 
      $rootScope.spinner = $rootScope.spinner ? $rootScope.spinner : startSpinner(); */ 
      return promise.then(
      // Success: just return the response 
      function (response) { 
       return response; 
      }, 
      // Error: check the error status to get only the 401 
      function (response) { 
       if (response.status === 404) $location.url('/404'); 
       return $q.reject(response); 
      }); 
     } 
    }); 

    $routeProvider.when("/", { 
     templateUrl: "views/homepage.html", 
     controller: "homeC" 
    }).when("/about", { 
     templateUrl: "views/about.html", 
     controller: "RouteC" 
    }).when("/about/our-team", { 
     templateUrl: "views/our-team.html", 
     controller: "aboutC" 
    }).when("/who-we-are", { 
     templateUrl: "views/page.html", 
     controller: "RouteC" 
    }).when("/what-we-do", { 
     templateUrl: "views/page.html", 
     controller: "RouteC" 
    }).when("/about/manifesto", { 
     templateUrl: "views/manifesto.html", 
     controller: "RouteC" 
    }).when("/about/testimonials", { 
     templateUrl: "views/testimonials.html", 
     controller: "testimonialC" 
    }).when("/about/awards", { 
     templateUrl: "views/awards.html", 
     controller: "RouteC" 
    }).when("/services", { 
     redirectTo: "/services/design" 
    }).when("/services/marketing", { 
     templateUrl: "views/services-marketing.html", 
     controller: "services_marketing" 
    }).when("/services/design", { 
     templateUrl: "views/services-design.html", 
     controller: "services_design" 
    }).when("/services/ecommerce", { 
     templateUrl: "views/services-ecommerce.html", 
     controller: "services_ecommerce" 
    }).when("/services/development", { 
     templateUrl: "views/services-development.html", 
     controller: "services_development" 
    }).when("/services/mobile", { 
     templateUrl: "views/services-mobile.html", 
     controller: "services_mobile" 
    }).when("/services/marketing/:slug", { 
     templateUrl: "views/services.html", 
     controller: "services_marketing_internal" 
    }).when("/services/:slug", { 
     templateUrl: "views/services.html", 
     controller: "services_internal" 
    }).when("/portfolio", { 
     redirectTo: "/portfolio/website" 
    }).when("/portfolio/:slug", { 
     templateUrl: "views/portfolio.php", 
     controller: "portfolioC" 
    }).when("/portfolio/:category/:slug", { 
     templateUrl: "views/portfolio-single.php", 
     controller: "portfolio_internal" 
    }).when("/blog-home", { 
     templateUrl: "views/blog-home.html", 
     controller: "RouteC" 
    }).when("/blog-post", { 
     templateUrl: "views/blog-post.html", 
     controller: "RouteC" 
    }).when("/contact", { 
     templateUrl: "views/contact.php", 
     controller: "contactC" 
    }).when("/debug", { 
     templateUrl: "views/qunit.html", 
     controller: "qunitC" 
    }).when("/404", { 
     templateUrl: "views/error-404.html" 
    }).when("/sitemap", { 
     templateUrl: "views/sitemap.php" 
    }).otherwise({ 
     redirectTo: "/404" 
    }); 

    //$locationProvider.hashPrefix('!'); //This seems to be the code which handles the redirect. 
}).run(function ($rootScope, $location) { 
    $rootScope.$apply.pathTo = function (url) { 
     $location.path(url); 
    }; 
+0

이것은 내게 머물러있는 첫 번째 물건 중 하나 였지만 완전히 제거해도 아무 것도 바뀌지 않았습니다. 그러나 나는 '대답'이라고 표시된 실제 해결책을 가지고있다. –

관련 문제