Encoding of [removed].hash

前端 未结 4 1845
死守一世寂寞
死守一世寂寞 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:23

    Answering to my own question, my current solution is to parse window.location.href instead of using window.location.hash, because the former is always (i.e. in every browser) url-encoded. Therefore the decodeURIComponent function CMS proposed can always be used safely. YUI does the same, therefore it can't be that wrong...

提交回复
热议问题