Extract external HTML via a hidden text/html-object
by
, 05-05-2009 at 09:32 AM (30517 Views)
In the head:
In the body:Code:<!--[if IE]> <script type="text/javascript"> document.write('<object type="text/html" id="object_id" width="0" height="0" data="menu.html"><\/object>'); onload=function(){ document.getElementById('main_page_id').innerHTML = document.getElementById('object_id').object.documentElement.innerHTML; } </script> <![endif]--> <!--[if !IE]><!--> <script type="text/javascript"> /*We could do a document.write for the object, but we do it the dom-way */ var OBJ = document.createElement("object"); OBJ.setAttribute("type", "text/html"); OBJ.setAttribute("data", "menu.html"); OBJ.setAttribute("id", "object_id"); OBJ.setAttribute("width", "0px"); OBJ.setAttribute("height", "0px"); document.documentElement.appendChild(OBJ); onload=function(){ transfer = document.getElementById('main_page_id'); while(transfer.hasChildNodes())transfer.removeChild(transfer.firstChild); transfer.appendChild(document.getElementById( 'object_id').contentDocument.documentElement.cloneNode(true)); } </script><!--<![endif]-->See HERE for demos and detailed explanations.Code:<div id="main_page_id"></div>
===
Arie Molendijk.