2
내 AJAX 기능이 URI의 해시 부분을 변경할 때 링크를 복사하여 붙여 넣으면 직접 액세스 할 수 있도록 리디렉터를 설정하려고합니다. . 내 현재 기능은 아래와 같습니다. 그러나 항상 false를 반환합니다!"#"에 대한 Javascript window.location 검색은 true를 반환하지 않습니다.
//If a hash is found, redirect it
var current_uri = String(window.location);
if (current_uri.search('/\#/') != -1) {
var current_uri_array = current_uri.split('#');
window.location = current_uri[1];
}
어떻게이 코드를 변경하여이 작업을 수행 할 수 있습니까? 이 작업을 수행하는 더 좋은 방법이 있습니까? 도움 주셔서 감사합니다.
코드로 업데이트 :
if (window.location.hash) {
window.location = window.location.hash.substring(1);
} 일
. ;
나는에 코드를 업데이트 : // 해시가 발견되면, 그것은 경우 (하면 window.location.hash) { 에서는 window.location =에서는 window.location 리디렉션합니다. hash.substring (1); } 그리고 이것은 효과가있었습니다. 고맙습니다. – ensnare