Could a page display diferrent content if the URL hash changes?

前端 未结 7 1830
名媛妹妹
名媛妹妹 2021-01-14 15:24

How could a page display different content based on the URL hash?

I\'m not talking about the browser scrolling down to display the anchored section, but something li

7条回答
  •  礼貌的吻别
    2021-01-14 15:52

    Oh yes - it's becoming a common pattern to handle page-state-to-URL persistence when content is AJAX driven.

    Javascript can access this value via window.location.hash. Once that's done, you can perform any actions based on the value of that hash

    • Show/hide nodes
    • Makes other AJAX calls
    • Change page titles or colors
    • Swap images
    • etc

    Really, any DHTML effect.

提交回复
热议问题