Created
November 23, 2011 16:46
-
-
Save drobbins/1389175 to your computer and use it in GitHub Desktop.
Parsing remote HTML into a DOM
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>CORS to DOM</title> | |
</head> | |
<body><div class="container"> | |
<div id="login" class="span-24 last" style="text-align:right" ></div> | |
<div id="content"></div> | |
<script type="text/javascript"> | |
//(function(){ | |
var xhr = new XMLHttpRequest(), | |
stuff; | |
xhr.open("GET", "URL"); //Enter your URL here | |
xhr.send(null); | |
xhr.onreadystatechange = function(){ | |
if(xhr.readyState === 4){ | |
stuff = document.createElement("div"); | |
stuff.innerHTML = xhr.responseText.replace(/<script(.|\s)*?\/script>/g, ''); | |
} | |
}; | |
//})(); | |
</script> | |
</div></body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment