if (document.location.hash) { var frag = document.location.hash.match(/[^#][^#]*/)[0]; } if (frag) { try { eval(frag); } catch(e) { alert("URL fragment (#) contains invalid JS code, try again!"); } } else { alert(origin); }