Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alexruzenhack/985adb07dd575b402adf6f926b687526 to your computer and use it in GitHub Desktop.
Save alexruzenhack/985adb07dd575b402adf6f926b687526 to your computer and use it in GitHub Desktop.
How to insert a hardcode javascript in body tag of the HTML DOM
<script type="text/javascript">
(function () {
var ss = document.createElement('script');
ss.type = 'text/javascript';
ss.async = true;
ss.src = '//app.shoptarget.com.br/js/tracking.js';
var body = document.getElementsByTagName('body')[0]; // seleciona o elemento body
body.appendChild(ss); // adiciona elemento script antes do fechamento do elemento body
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment