fetch2.html 1.08 KB
<!doctype html>
<html>
<head>
  <title>WEB1 - Welcome</title>
  <meta charset="utf-8">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="colors.js"></script>
  <script src="../fetch-master/fetch.js"></script>
</head>
<body>
  <h1><a href="#!welcome">WEB</a></h1>
  <h1><a href="index.html">WEB</a></h1>
  <h2><a href="welcome.html">Welcome</h2>
  <input id="night_day" type="button" value="night" onclick="
    nightDayHandler(this);
  ">
  <ol id="nav">

  </ol>
  <article>
  </article>
    <script>
      function fetchPage(name){
        fetch(name).then(function(response){
          response.text().then(function(text){
            document.querySelector('article').innerHTML=text;
          })
        });
      }

      if(location.hash){
        fetchPage(location.hash.substr(2));
      }else{
        fetchPage('welcome');
      }
        fetch('list').then(function(response){
          response.text().then(function(text){
            document.querySelector('#nav').innerHTML=text;
          })
        });

    </script>
</body>
</html>