IFRAME
tag with SRC=FILENAME.HTM
(in Explorer 4+ and Netscape 6)
You can use JavaScript to detect the browser name and version
(see Client Information) and then
generate the necessary
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>