Entry
How can I embed an external URL into an HTML document?
How can I embed an external URL into an HTML document?
Mar 6th, 2000 02:23
Martin Honnen, Per M Knutsen,
You should mainly use HTML elements like IFRAMEs or ILAYERs to do that.
IE and NN6 supports inline frames
<IFRAME SRC="whatever.html"></IFRAME>
while NN4 suppors inline layers
<ILAYER SRC="whatever.html></ILAYER>
To have cross browser HTML you can use
<IFRAME SRC="whatever.html">
<ILAYER SRC="whatever.html"></ILAYER>
</IFRAME>
as thereby IE and NN6 will display the IFRAME and ignore the ILAYER
while NN4 ignore the IFRAME and shows the ILAYER.
Note that while IFRAMEs allow for scrolling ILAYERs don't support that.
Thus you can restrict WIDTH/HEIGHT for the IFRAME and have scrollbars
to display the complete document while with ILAYERs always the complete
document is inserted.
If you want to add embed external documents after the document is
loaded have for NN4 a look at
http://www.faqts.com/knowledge-base/view.phtml/aid/1540/fid/128/lang/en
how to dynamically create layers e.g.
var layer = new Layer(200);
and at
http://www.faqts.com/knowledge-base/view.phtml/aid/1272/fid/128/lang/en
how to load external documents into a layer e.g.
layer.src = 'http://javascript.faqts.com';
layer.visibility = 'show';
For IE4/5 and NN6 have a look at
http://www.faqts.com/knowledge-base/view.phtml/aid/1540/fid/128/lang/en
but don't insert a positioned DIV but directly an IFRAME into the
document. For instance the following adds this knowledge base to an
IE4/5 page:
var html = '<IFRAME SRC="http://javascript.faqts.com"><\/IFRAME>';
document.body.insertAdjacentHTML('beforeEnd', html);
For NN6:
var iframe = document.createElement('IFRAME');
iframe.src = 'http://javascript.faqts.com';
document.body.appendChild(iframe);