首页 > 解决方案 > 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">&#42;</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>

在此处输入图像描述

刷新后是否有机会保留第二页?

标签: htmlcss

解决方案


刷新页面将完全以初始状态重新加载页面,我假设它只显示“第一页”。这是预期的行为。


推荐阅读