Question: Can I display an external HTML file as part of my page?
Answer: Yes, you can display an external HTML file on your page by using:
LAYER
or ILAYER
tags with SRC=FILENAME.HTM
(in Netscape 4)
IFRAME
tag with SRC=FILENAME.HTM
(in Explorer 4+ and Netscape 6)
IFRAME
or
LAYER
tags.
Here's an example:
In the above example, we've created a JavaScript function
insertExternalFile()
for detecting the client browser and generating the necessary tags.
In order to insert an external file, we called
insertExternalFile()
passing the file name as a parameter.
The function also takes two other parameters:
the width and height of the area where you'd like
to display the inserted file.
Thus, each of the external files
inserted_file1.htm
and
inserted_file2.htm
was embedded in the page using the following code:
insertExternalFile("inserted_file.htm",layer_width,layer_height)
The JavaScript code of the function
insertExternalFile()
is contained within the HEAD
section of the page:
<script language="JavaScript"> <!-- function insertExternalFile(fname,W,H) { if (navigator.appName.indexOf("Microsoft")!=-1 || navigator.appName=="Netscape" && parseInt(navigator.appVersion)>4 ) { document.write('' +'<IFRAME src="'+fname+'" scrolling="no" frameborder=0 border=0' +(W==null ? '' : ' width='+W) +(H==null ? '' : ' height='+H) +'></IFRAME>' ) } if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==4) { document.write('' +'<ILAYER>' +'<LAYER src="'+fname+'" ' +(W==null ? '' : ' width='+W) +(H==null ? '' : ' height='+H) +'></LAYER></ILAYER>' ) } } //--> </script>
Copyright © 1999-2011, JavaScripter.net.