1

I have this code which gets a specific web page content and loads it in an iframe. It works fine, unfortunately this content is in the body and doesn't come with CSS formatting, so I get an unformatted page. How can I get the stylesheet to come with the page content? Thanks in advance!

var getHTML = function (url, callback) { 
   if (!window.XMLHttpRequest) return;  
   var xhr = new XMLHttpRequest();  
   xhr.onload = function () {
      if (callback && typeof (callback) === 'function') {
            callback(this.responseXML);
      }
   } 
   xhr.open('GET', url);
   xhr.responseType = 'document';
   xhr.send();
};

function loadFram() {
   var src = document.getElementById("opt1").value;
   getHTML(src, function (response) {
     var x = document.getElementById("frame1");
     var y = (x.contentWindow || x.contentDocument);
     if (y.document)y = y.document;
     y.body.innerHTML = response.documentElement.querySelector('[id="Container"]').innerHTML;
     });
};
Adam
  • 47
  • 3

0 Answers0