Summary of methods to include file contents in HTML files

Summary of methods to include file contents in HTML files

In the forum, netizens often ask, can I read the contents of another html file in an html file? The answer is yes, and there is more than one way. In the past, I only used iframe to reference, and later I found several other methods. Today I will summarize these methods for your reference. I think the third method is better!

Several ways to introduce other HTML files in HTML files

1.IFrame introduction, look at the following code


Copy code
The code is as follows:

<IFRAME NAME="content_frame" width=100% height=40 marginwidth=0 marginheight=0 SRC="import.htm" ></IFRAME>

You will see an externally imported file, but you will find something like an outer frame surrounding it. You can use


Copy code
The code is as follows:

<iframe name="content_frame" marginwidth=0 marginheight=0 width=100% height=40 src="import.htm" frameborder=0></iframe>

But you will find that there is still a problem, that is, the background color is different. You can just use the same background color in the imported file import.htm, but if you use

If you are using IE5.5, you can read this article about transparent colors. If you want to import a long file without scroll bars, add this to the body of import.htm:

Enter scroll=no

*Disadvantages: Unable to do navigation jump, jump inside iframe, content overlap appears

2.<object> method


Copy code
The code is as follows:

<object style="border:0px" type="text/x-scriptlet" data="import.htm" width=100% height=30></object>

object tag — defines an embedded object (e.g. image, media, code, etc.)

* It does not conform to the concept of standard web design and has been abandoned by standard web design.

3.Behavior download method


Copy code
The code is as follows:

<span id=showImport></span>
<IE:Download ID="oDownload" STYLE="behavior:url(#default#download)" />
<script>
function onDownloadDone(downDate){
showImport.innerHTML=downDate
}
oDownload.startDownload('import.htm',onDownloadDone)
</script>

<<:  How to implement rounded corners with CSS3 using JS

>>:  Pure CSS code to achieve flow and dynamic line effects

Recommend

Several ways to shut down Hyper-V service under Windows 10

When using VMware Workstation to open a virtual m...

Correct use of MySQL partition tables

Overview of MySQL Partitioned Tables We often enc...

Specific steps to use vant framework in WeChat applet

Table of contents 1. Open the project directory o...

Vue+Element realizes paging effect

This article example shares the specific code of ...

Super detailed steps to install zabbix3.0 on centos7

Preface Recently, part of the company's busin...

Core skills that web front-end development engineers need to master

The content involved in Web front-end development...

The meaning and usage of linux cd

What does linux cd mean? In Linux, cd means chang...

HTML5+CSS3 header creation example and update

Last time, we came up with two header layouts, on...

Tkinter uses js canvas to achieve gradient color

Table of contents 1. Use RGB to represent color 2...

JavaScript implements simple date effects

The specific code of JavaScript date effects is f...

Implementing shopping cart function based on vuex

This article example shares the specific code of ...

Mysql join query principle knowledge points

Mysql join query 1. Basic concepts Connect each r...

Simple usage example of MySQL 8.0 recursive query

Preface This article uses the new features of MyS...

Three.js sample code for implementing dewdrop animation effect

Preface Hello everyone, this is the CSS wizard - ...