Created
January 4, 2022 21:30
-
-
Save ricealexander/b53ab012a31c655cc14d860da102e9a4 to your computer and use it in GitHub Desktop.
Script that injects HTML content after itself. An alternative to document.write
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Grove and other Single-Page Applications do not allow document.write() to be loaded on | |
pages that have been navigated to. In cases where absolutely necessary, we can use an | |
approach where content is self-injected. --> | |
<script id="embed"> | |
var script = document.querySelector('#embed'); | |
script.insertAdjacentHTML('afterend', "Hello World"); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment