Last active
July 3, 2019 15:53
-
-
Save easierbycode/394f7cd6a4987165f88de3468a431e88 to your computer and use it in GitHub Desktop.
URLSearchParams
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
| // URL example: | |
| // https://foo.com/game.html?src=asteroids | |
| var urlParams = new URLSearchParams(window.location.search); | |
| var filename = urlParams.get('src'); | |
| var s = document.createElement('script'); | |
| s.type = 'text/javascript'; | |
| s.src = 'js/' + decodeURI(filename) + '.js'; | |
| document.body.appendChild(s); |
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
| Just when I thought I was out, they pull me back in. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment