Skip to content

Instantly share code, notes, and snippets.

@4lg4
Created March 28, 2018 06:30
Show Gist options
  • Save 4lg4/163ebdbb352da574a65ebd88399e4714 to your computer and use it in GitHub Desktop.
Save 4lg4/163ebdbb352da574a65ebd88399e4714 to your computer and use it in GitHub Desktop.
Javascript passing variables to caller script
<script src=".." one="1" two="2"></script>
document.currentScript.getAttribute('one'); //1
document.currentScript.getAttribute('two'); //2
document.currentScript = document.currentScript || (function() {
var scripts = document.getElementsByTagName('script');
return scripts[scripts.length - 1];
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment