1 Reply Latest reply on Nov 15, 2008 5:30 PM by Dr. Fred Mbogo

    Loading HTM into DIV containers

      I need to build an application based on our website that uses different div containers to hold multiple web pages

      we use a this script to load the pages and it all works fine in the browswer environments.

      function htmlloader(url,target) {
      // native XMLHttpRequest object
      document.getElementById(target).innerHTML = 'sending...';
      if (window.XMLHttpRequest) {
      req = new XMLHttpRequest();
      req.onreadystatechange = function() {htmlloaderDone(target);};
      req.open("GET", url, true);
      // IE/Windows ActiveX version
      } else if (window.ActiveXObject) {
      req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) {
      req.onreadystatechange = function() {htmlloaderDone(target);};
      req.open("GET", url, true);
      function htmlloaderDone(target) {
      // only if req is "loaded"
      if (req.readyState == 4) {
      // only if "OK"
      if (req.status == 200) {
      results = req.responseText;
      document.getElementById(target).innerHTML = results;
      } else {
      document.getElementById(target).innerHTML="htmlloader error:\n" +

      The problem is that the javascript functionson the loaded pages fail to work once loaded into the divs in the AIR application

      can any one help

        • 1. Re: Loading HTM into DIV containers
          Dr. Fred Mbogo
          I suspect you'll find that the code doesn't work on Safari or Google Chrome, either. Those and AIR are all based on WebKit, so if it fails on one, it should fail on the others.

          I suspect your hand-rolled XHR code is to blame. Either get rid of the MSIE code entirely, or, better, start using a JS framework like Prototype or jQuery which handles these cross-browser compatibility issues for you. The code is shorter when you use the JS framework, which is why it's better. The fewer LOC you write, the fewer you have to debug.