Skip to content

Instantly share code, notes, and snippets.

@SukkaW
Created November 9, 2018 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SukkaW/954eb690be7cf68b411a645e93adbd70 to your computer and use it in GitHub Desktop.
Save SukkaW/954eb690be7cf68b411a645e93adbd70 to your computer and use it in GitHub Desktop.
Return to previous page.
/*!
* return-prev.js
* Author: SukkaW (https://skk.moe)
* License: MIT
*
* @param {Object} Element selector for link
*/
(function(El) {
if (document.referrer && document.location.host && document.referrer.match(new RegExp("^https?://" + document.location.host))) {
El.setAttribute("href", document.referrer);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment