Skip to content

Instantly share code, notes, and snippets.

@marcus-herrmann
Created June 21, 2020 12:12
Show Gist options
  • Save marcus-herrmann/540a9419afc2861dee8484587565e5ec to your computer and use it in GitHub Desktop.
Save marcus-herrmann/540a9419afc2861dee8484587565e5ec to your computer and use it in GitHub Desktop.
if (document.referrer) {
const referrerHostname = (new URL(document.referrer)).hostname;
let main;
if (location.hostname === referrerHostname) {
main = document.querySelector('main');
if (!!main) {
main.focus();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment