Ajax

fragment identifier를 이용한 초기 페이지 기능 구현

appmaster 2021. 3. 12. 17:27

만약 id값이 three인 구역으로 이동할때, url을 이용하고 싶다면 다음과 같이 주소로 입력하면 됩니다.

http://127.0.0.1:5500/Path.html#three

 

이런과정을 나눈다고해서 fragment라고 하고 그 fragment중에 구분짓기위해서 identifier라고 합니다.

그래서 이러한것을 fragment identifier라고 합니다.

 

 

다음과 같이 태그를만들어서 화면에 three를 클릭하면 해당구역으로 이동하게 됩니다.

 

 

해쉬값이 무엇이냐에 따라서 ajax로 다른페이지를 로드해서 시작되는페이지를 세팅할 수 있게 됩니다. 

<!DOCTYPE html>

<html>

<a href="#three">three로 이동</a>

<body>
    <p>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
        standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
        a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,
        remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
        Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions
        of Lorem Ipsum.
    </p>
    <p>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
        standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
        a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,
        remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
        Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions
        of Lorem Ipsum.
    </p>
    <p id="three">
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
        standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
        a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,
        remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
        Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions
        of Lorem Ipsum.
    </p>

    <script>
        
    </script>
</body>

</html>

'Ajax' 카테고리의 다른 글

리펙토링 - 함수화  (0) 2021.03.12
Ajax 이용해보기  (0) 2021.03.12
fetch API - response 객체  (0) 2021.03.12
fetch API 기본 사용법  (0) 2021.03.12
Ajax란?  (0) 2021.03.12