Encoding of [removed].hash

前端 未结 4 1844
死守一世寂寞
死守一世寂寞 2020-12-13 02:22

Does window.location.hash contain the encoded or decoded representation of the url part?

When I open the same url (http://localhost/something/#%C3

4条回答
  •  抹茶落季
    2020-12-13 02:24

    You can use decodeURIComponent, it will return in all cases:

    decodeURIComponent('#%C3%BC'); // #ü
    decodeURIComponent('#ü'); // #ü
    

    Try it out here.

提交回复
热议问题