Created
March 3, 2011 21:41
-
-
Save tlrobinson/853658 to your computer and use it in GitHub Desktop.
This file contains 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
// Injecting JavaScript | |
// Basic compact | |
document.body.appendChild(document.createElement("script")).src="foo.js" | |
// Function wrapped | |
(function(d){d.body.appendChild(d.createElement("script")).src="foo.js"})(document) | |
// With "with" | |
with(document){body.appendChild(createElement("script")).src="foo.js"} | |
// Injecting CSS | |
// Basic compact (leaks a global) | |
l=document.createElement("link");l.rel="stylesheet";l.href="foo.css";document.body.appendChild(l) | |
// Function wrapped | |
(function(d,l){l=d.createElement("link");l.rel="stylesheet";l.href="foo.css";d.body.appendChild(l)})(document) | |
// With "with" | |
with(document){with(body.appendChild(createElement("link"))){rel="stylesheet";href="foo.css"}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment