반응형
윈도우의 URL 해시를 다른 응답으로 대체하려면 어떻게 해야 합니까?
교체 방법으로 해시 URL(document.location.hash)을 변경하려고 하는데 작동하지 않습니다.
$(function(){
var anchor = document.location.hash;
//this returns me a string value like '#categories'
$('span').click(function(){
$(window).attr('url').replace(anchor,'#food');
//try to change current url.hash '#categories'
//with another string, I stucked here.
});
});
페이지 변경/새로 고침을 원하지 않고 응답 없이 URL만 교체하고 싶습니다.
참고: href="#food" 솔루션으로 이 문제를 해결하고 싶지 않습니다.
둘중 하나의 용도location
아니면window.location
대신에document.location
후자는 비표준이기 때문에
window.location.hash = '#food';
이렇게 하면 URL의 해시가 사용자가 설정한 값으로 바뀝니다.
다른 점은.history.replaceState()
닻으로 스크롤하는 것이 아니라 네비게이션 바에서만 교체할 수 있습니다.모든 주요 브라우저에서 지원됩니다.
history.replaceState(undefined, undefined, "#hash_value")
언급URL : https://stackoverflow.com/questions/11588482/how-can-i-replace-a-windows-url-hash-with-another-response
반응형
'programing' 카테고리의 다른 글
즐겨찾기 컨텐츠가 웹뷰에 올바르게 표시되지 않음 (0) | 2023.09.14 |
---|---|
아두이노 HTTPS 지원 예정 (0) | 2023.09.14 |
Android용 XML 특성의 물음표(?) (0) | 2023.09.14 |
Oracle 데이터베이스에서 데이터 아카이빙을 수행하는 가장 좋은 방법은 무엇입니까? (0) | 2023.09.14 |
PHP - 여러 파일 업로드 (0) | 2023.09.14 |