创建 iframe 可以使用 HTML 的
以下是一个简单的示例,将网页 http://www.example.com 嵌入到当前页面中:
<iframe src="http://www.example.com" width="600" height="400"></iframe>
其中 src
属性指定要嵌入的网页地址,width
和 height
属性指定 iframe 的宽度和高度。
除了嵌入其他网页,也可以使用 iframe 将其他网页包含到当前页面中,实现网页的模块化。
以下是一个示例,将 http://www.example.com 的头部和脚部嵌入到当前页面中:
<iframe src="http://www.example.com/header.html" width="100%" height="100"></iframe>
<iframe src="http://www.example.com/footer.html" width="100%" height="100"></iframe>
其中 http://www.example.com/header.html 和 http://www.example.com/footer.html 是要包含的网页的地址。
需要注意的是,由于安全原因,如果要包含的网页和当前页面不在同一个域名下,会出现跨域问题。