Posted By

brianyang on 06/10/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wirenaught


XMLHttpRequest Script Injection


 / Published in: JavaScript
 

  1. var xhr = new XMLHttpRequest();
  2. xhr.open("get", "file1.js", true);
  3. xhr.onreadystatechange = function(){
  4. if (xhr.readyState == 4){
  5. if (xhr.status >= 200 && xhr.status < 300 || xhr.status == 304){
  6. var script = document.createElement("script");
  7. script.type = "text/javascript";
  8. script.text = xhr.responseText;
  9. document.body.appendChild(script);
  10. }
  11. }
  12. };
  13. xhr.send(null);

Report this snippet  

You need to login to post a comment.