<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multiple HTML Pages Combined</title>
<style>
/* Basic styling to separate sections */
.page {
margin: 20px;
padding: 20px;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<!-- Page 1 -->
<div class="page" id="page1">
<h1>Page 1 Title</h1>
<p>This is the content of page 1.</p>
</div>
<!-- Page 2 -->
<div class="page" id="page2">
<h1>Page 2 Title</h1>
<p>This is the content of page 2.</p>
</div>
<!-- Page 3 -->
<div class="page" id="page3">
<h1>Page 3 Title</h1>
<p>This is the content of page 3.</p>
</div>
<script>
// JavaScript code to dynamically load content from other HTML files if needed
// Example using fetch API to load external HTML content into divs
function loadPageContent(pageId, url) {
fetch(url)
.then(response => response.text())
.then(data => {
document.getElementById(pageId).innerHTML = data;
})
.catch(error => console.error('Error loading page content:', error));
}
// Example usage:
// Uncomment the lines below and provide valid URLs to load external HTML content
// loadPageContent('page1', 'path/to/page1.html');
// loadPageContent('page2', 'path/to/page2.html');
// loadPageContent('page3', 'path/to/page3.html');
</script>
</body>
</html>
<div>标签包裹,并通过id属性区分不同的页面。fetch API动态加载外部HTML文件的内容到指定的<div>中。你可以根据需要取消注释并提供有效的URL来加载外部内容。如果你有多个独立的HTML文件,可以使用JavaScript动态加载这些文件的内容到当前页面中,从而实现多个HTML页面拼接成一个页面的效果。
上一篇:html表格样式
下一篇:html符号
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站