html - HTML 页面有 2 个页面,只有第 1 个页面被刷新
问题描述
根据以下线程,我将 HTML 页面的内容划分为 2 个单独的子页面:
一个 HTML 文件中的多个不同页面 https://www.codegrepper.com/code-examples/html/multiple+pages+in+one+html+file
所以,我的代码如下所示:
... <script>
function show(shown, hidden) {
document.getElementById(shown).style.display='block';
document.getElementById(hidden).style.display='none';
return false;
}
</script>
...
</head>
<body>
<div id="header"></div>
<main>
<section class="container">
<div class="top">
<h1>Survey form</h1>
</div>
<article class="internal">
<div>
<h5 class="notification">Hi (...)</h5>
<p><span class="asterisk">*</span> Required</p>
<div id="Page1"> <!--SURVEY FORM PAGE 1-->
<h2 class="property">Property information</h2>
<form id="form1" action="" onsubmit="mySubmit()" onreset="myReset()">
...COntent...
<a href="#" class="navbtn1" onclick="return show('Page2','Page1');">Next</a>
</form>
</div>
<div id="Page2" style="display:none"> <!--SURVEY FORM PAGE 2-->
<h2 class="property">Layout</h2>
<form id="form2" action="" onsubmit="mySubmit()" onreset="myReset()">
...content...
<a href="#" class="navbtn2" onclick="return show('Page1','Page2');">Previous</a>
<br>
</form>
</div>
刷新后是否有机会保留第二页?
解决方案
刷新页面将完全以初始状态重新加载页面,我假设它只显示“第一页”。这是预期的行为。
推荐阅读
- python - 当我尝试安装有序集时出现 UnicodeDecodeError
- hibernate - 命名查询中的错误
- android - 如何在 Jmeter 中解决 Android 应用程序的令牌问题
- angular - 角度模板中的 attr.property 和 property 有什么区别?
- android - 如何使用 gradle 使用平台密钥签署 android 应用程序?
- facebook-graph-api - 如何从 facebook 图形 API 资源管理器中的 facebook 营销 API 获取广告引用的我自己的网站网址?
- html - 在我更新 Audio 元素中的 `src` 之后,事件监听器会发生什么?(反应)
- android - ActionBar 中的 SearchView 不是全宽
- laravel - PostgreSQL 中的纬度和经度必须使用哪种数据类型?
- java - Selenium div 下拉列表 - 元素不可见