Use encodeURIComponent for window.location.hash