Skip to content

Instantly share code, notes, and snippets.

@drobbins
Created November 23, 2011 16:46
Show Gist options
  • Save drobbins/1389175 to your computer and use it in GitHub Desktop.
Save drobbins/1389175 to your computer and use it in GitHub Desktop.
Parsing remote HTML into a DOM
<!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