如圖:瀏覽器
在火狐瀏覽器中window.location.hash.substring(1)返回字符串被編碼,例如<script>alert(1)</script>返回後成爲%3Cscript%3Ealert(1)%3C/script%3Ethis
這是在火狐瀏覽器中的bug,在其餘瀏覽器中是正常返回的,例如(電腦暫時只有firfox就用手機uc代替了):編碼
window.location.hash should always return urlencoded string, but this is a bug in Firefox
url
參考:http://stackoverflow.com/questions/824040/doing-substring-in-window-location-hash#code