Posted By

matski on 03/27/09


Tagged

css javascript textmate frames httprequest jah kevinmarks


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

matski


JS "JAH" Script by Kevin Marks


 / Published in: Other
 

  1. function jah(url,target) {
  2. // native XMLHttpRequest object
  3. document.getElementById(target).innerHTML = ' ';
  4. if (window.XMLHttpRequest) {
  5. req = new XMLHttpRequest();
  6. req.onreadystatechange = function() {jahDone(target);};
  7. req.open("GET", url, true);
  8. req.send(null);
  9. // IE/Windows ActiveX version
  10. } else if (window.ActiveXObject) {
  11. req = new ActiveXObject("Microsoft.XMLHTTP");
  12. if (req) {
  13. req.onreadystatechange = function() {jahDone(target);};
  14. req.open("GET", url, true);
  15. req.send();
  16. }
  17. }
  18. }
  19.  
  20. function jahDone(target) {
  21. // only if req is "loaded"
  22. if (req.readyState == 4) {
  23. // only if "OK"
  24. if (req.status == 200) {
  25. results = req.responseText;
  26. document.getElementById(target).innerHTML = results;
  27. } else {
  28. document.getElementById(target).innerHTML="Whoops! n" +
  29. req.statusText;
  30. }
  31. }
  32. }
  33.  

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: matski on March 27, 2009

In order to avoid using HTML framesets but achieve the same effect with CSS instead (why? to replicate the Indexhibit layout), I used this to load content into a with a specified ID. There's probably a cleaner way to do it, but this worked for me...

More here: Code: http://homepage.mac.com/kevinmarks/staticjah.html Info: http://en.wikipedia.org/wiki/Kevin_Marks

You need to login to post a comment.