Button for password

I have an HTML page I want to keep private. So i added a passwprd button. I went to add the link of the page I want it to go to but it won’t for some reason. Never had a problem linkin g before.

<!DOCTYPE html>
<html>
<head>	
  <meta charset="UTF-8">
  <title>Home - Charisma Communications</title>
  <link rel="stylesheet" href="css/style.css" type="text/css">
	
	<script>
        function promptPassword() {
            const password = prompt("4228542:");
            if (password) {
                alert("Password entered: " + password);
            } else {
                alert("No password entered.");
            }
        }
    </script>
	
	
</head>
<body>
  <div id="page">
    <div id="header">
      <a href="index.html" id="logo"><img src="images/logo.png" alt="LOGO"></a>
      <ul id="navigation">
        <li class="selected">
          <a href="index.html" title="Home"></a>
        </li>
        <li>
          <a href="thalidomide.html">Thalidomide</a>
        </li>
        <li>
          <a href="resilience.html">Resilience</a>
        </li>
        <li>
          <a href="speaker.html">Speaker</a>
        </li>
		<li>
		  <a href="blog.html">blog</a>
		</li>  
        <li>
          <a href="gallery.html">Gallery</a>
        </li>
        <li class="last-child">
          <a href="contact.html">Contact us</a>
        </li>
		 <a href="policy.html">
		  <button type="button">Blog Policies</button>
		  </a>  
      </ul><br>
      <div id="contents">
        <div class="background">
	<!-- transfer starts -->
        
			<br>
          <img src="images/head2.png" class="float-right" width="256" height="387" alt="Louis Gasudry"/>
		  <h2>Louis gaudry</h2>
          <br>
          <p>Challenges in life are universal; everyone faces them, and I'm no exception. Growing up, learning to do things independently was a daily challenge. As I matured, these challenges evolved, requiring me to become self-sufficient not only at home but also at school, college, work, and in public.</p>
          <p>I've always enjoyed trying new things, regardless of their scale. For example, I took up swimming, biking, archery, and even horseback riding. Photography particularly piqued my curiosity. We always had a camera in the family growing up. The early ones, like the old Instamatic film cameras, were challenging for me to handle, but as cameras evolved, I found ways to use them.</p>
          <p>Looking back, I realize I’ve always been interested in accessible technology. In high school, I took up photography. Figuring out how to handle a camera was a challenge, but with the help of a supportive teacher, I managed.</p>
          <p>Many years later, I decided to go to college and earn a certificate in website development, which included a photography module. We used digital cameras, and since they were heavy, I had to rely on a tripod. While that worked, I didn’t want to depend on a tripod all the time.</p>
          <p>Eventually, my passion for photography was rekindled. I began researching what camera would best fit me and found one with a pull-out back screen. Over time, I even made my own custom hand grip to better suit my needs. My first camera was a Lumix FZ300, which I later upgraded to a Nikon D7500.</p>
          <div class="gallery">
            <div class="thumbnail">
              <a href="images/fz300.jpg" data-lightbox="gallery" data-title="Lumix FZ300"><img src="images/fz300.jpg" alt="Lumix FZ300"></a>
            </div>
            <div class="thumbnail">
              <a href="images/nikon.jpg" data-lightbox="gallery" data-title="Nikon D7500"><img src="images/nikon.jpg" alt="Nikon D7500"></a>
            </div>
          </div>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.3/js/lightbox-plus-jquery.min.js"></script>
        </div><br>
        <blockquote>
          <h2>Because accessibility is important to me, I started a website called Capture Ability, which provides information on photography for people of all abilities.</h2>
			 <button onclick="promptPassword()">Enter Password</button>
        </blockquote>
		
      </div>
    </div>

		<!-- transfer ends -->
      <div id="footer">
        <div class="connect"></div>
        <p>Copyright © 2024. Charisma Communications All Rights Reserved.</p>
      </div>
    </div>

</body>
</html>

Page i’m linkin g below,

<!DOCTYPE html>
<html>
<head>
	
	<meta charset="UTF-8">
	<title>News - Charisma Communications</title>
	<link rel="stylesheet" href="css/style.css" type="text/css">
	<!--[if IE]>
		<link rel="stylesheet" href="css/ie.css" type="text/css" charset="utf-8">
	<![endif]-->
</head>
<body>
	<div id="page">
		<div id="header">
			<a href="index.html" id="logo"><img src="images/logo.png" alt="LOGO"></a>
			<ul id="navigation">
				<li class="selected">
					 <a href="index.html" title="Home"></a>
        </li>
        <li>
          <a href="thalidomide.html">Thalidomide</a>
        </li>
        <li>
          <a href="resilience.html">Resilience</a>
        </li>
        <li>
          <a href="speaker.html">Speaker</a>
        </li>
		<li>
		  <a href="blog.html">blog</a>
		</li>  
        <li>
          <a href="gallery.html">Gallery</a>
        </li>
        <li class="last-child">
          <a href="contact.html">Contact us</a>
        </li>
				
			</ul>
		</div>
		<div id="contents">
			<div class="background">
				<div id="news">
				
<div align="center"><iframe src="https://calendar.google.com/calendar/embed?src=2f8a668c5a09fcbcb68056e7cb6238501beada63b19c3434cd97a4c5e8203fee%40group.calendar.google.com&ctz=America%2FWinnipeg" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe></div>

	
				</div>
			</div>
		</div>
		<div id="footer">
			<div class="connect">
				<!---<a href="http://freewebsitetemplates.com/go/facebook/" target="_blank" class="facebook"></a> <a href="http://freewebsitetemplates.com/go/twitter/" target="_blank" class="twitter"></a> <a href="http://freewebsitetemplates.com/go/googleplus/" target="_blank" class="googleplus"></a>
--->
			</div>
			<p>
				Copyright &copy; 2024. Charisma Communications All Rights Reserved.
			</p>
		</div>
	</div>
</body>
</html>

Use the let keyword instead of const, it should work fine then

Sorry I’m not sure what you mean.

When declaring the password variable, use let instead of const so:
let password = prompt("4228542: ");

Just to make it clear, you can’t protect resources like that. It has to be server side, and you can’t have plain text passwords in the client code.

1 Like