Load only HTML in IFRAME

How can I only load the HTML of the page in IFRAME without automatically starting loading all the css, scripts, images and videos on the page?

Or you can get the event when the DOM is "ready" .. when the initial HTML is loaded and nothing else.

0


a source to share


4 answers


There is no cross browser way to do this. Some browsers provide events that fire when the DOM is loaded, such as DOMContentLoaded for Gecko.

jQuery implements this feature . I suggest you use jQuery for this:



$(document).ready(function () {
  // Function is called when the DOM is loaded.
});

      

Or check how jQuery implements it. See Function bindReady

in the jQuery source code .

+3


a source


To get only HTML content, try using an AJAX call. This will, of course, return the content to a variable, but you can handle it however you see fit later.



+3


a source


The short answer is "you can't."

Internet Explorer supports the propriatry attribute, which can prevent a script from executing , but it is not cross-browser and does not handle with images or stylesheets.

Several JS libraries implement a custom event that fires when the DOM is ready , but browsers load resources in parallel, so while an event may fire before all images and stylesheets have loaded, it is unlikely that they fire before other elements start loading ...

If you really want the page to load without these things, then process it on the server to cut out the HTML that includes them.

+2


a source


Set 'Content-type' to this HTML page for text / plain.

+2


a source







All Articles