I'm working on creating a special "ACCESS" button that will lead you to a secret webpage on a site once you enter a password

I used the GoDaddy website builder to create this website, limiting my options for customization. However, I am looking to implement password-only access (with the same password for everyone) to a specific page. This will require an input field for the password and a submit button.

As a complete beginner trying to learn on my own (probably very obvious!), I have put together the following code with minimal knowledge, but it seems like something is not right.

function passWord() {
  
  var testV = 1;
  var pass1 = prompt('Please Enter Your Password', '');
  
  while (testV < 3) {
    if (!pass1)
      history.go(-1);
    
    if (pass1.toLowerCase() == "mypassword") {
      window.open('http://www.website.com/webpage.html');
      break;
    }
    
    testV += 1;
    
    var pass1 =
      prompt('Access Denied - Password Incorrect, Please Try Again.', '');
  
  }
  
  if (pass1.toLowerCase() != "password" & testV == 3)
    history.go(-1);
  
  return " ";

}
input {
  background-color: #000000;
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: block;
  font-size: 16px;
  margin: auto;
  cursor: pointer;
}


/* Style the submit button */

input[type=submit] {
  background-color: #000000;
  color: white;
}


/* The message box is shown when the user clicks on the password field */

#message {
  display: none;
  background: #f1f1f1;
  color: #000;
  position: relative;
  padding: 20px;
  margin-top: 10px;
}

#message p {
  padding: 10px 35px;
  font-size: 18px;
}
<div class="container">
  <form action="/action_page.php">
    <input type="password" id="pwd" name="pwd" <br><br>
    <input type="submit" value="SUBMIT">
  </form>
</div>

Answer №1

Consider utilizing the location API as described in this resource

replace ->

window.open('http://www.example.com/page.html');

with

location.replace("http://www.example.com/page.html")

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The hover effect does not seem to be functioning properly within the <th>

I've been working on a tooltip feature that displays data in a message box when hovering over an icon based on its attribute. The following code is implemented for the mouseenter event. <span class='csTip fa fa-info-circle' csTipTerm=&a ...

Ever since I switched to a different monitor, my Javascript has suddenly stopped functioning

I'm encountering an issue where my JS stops working every time I switch displays within a single HTML file. I've attempted to replace the HTML onclick call with a JavaScript function, but the problem persists. Update: Apologies for the unclear e ...

What causes a delay in the start of a child process in Node.js?

I am in the process of developing a global node command line program that can execute any console command I provide it with in a new console window, whether on a Windows or Unix system. The goal is for the program to exit after it spawns its process so tha ...

Using jQuery to reference my custom attribute---"How to Use jQuery to reference My

Can you explain how to reference a tag using a custom attribute in jQuery? For example, if I have a tag like this: <a user="kasun" href="#" id="id1">Show More...</a> I want to reference the tag without using the id. So instead of using: $( ...

I need help determining the starting date and ending date of the week based on a given date

I am looking to determine the starting date (Monday) and ending date of a specified date using Javascript. For instance, if my date is 2015-11-20, then the starting date would be 2015-11-16 and the ending date would be 2015-11-21. ...

Allowing variables to be reached by different Node modules

I have a Node script that serves as both a cron job runner and an Express server. I want to be able to check the last time a job ran by making a request to an Express route. The main file index.js: require('@babel/register')({ }) import cron f ...

Arrange the elements in the array based on their parent relationships (using topological sort) and their importance within

My array contains objects with elements that are dependent on each other. To properly store this data in a database, I need to order the array by importance (based on parent dependency) and update all children's parent property with the corresponding ...

Struggling to change h2 style on WordPress?

In a WordPress page, I create three heading texts and adjust the CSS when the screen width is less than 820px. Here is the code snippet: <h1 class="block-h1">Heading 1</h1> <h2 class="block-h2">Heading 2</h2> <h3 class="block-h3 ...

The appearance of Google charts' X-axis leaves something to be desired

I used the google charts API to create a chart, but I am facing an issue with the X-axis labels. When I have multiple strings on the X-axis, the labels do not look good. I suspect that the problem lies in the X column type being a string instead of DATETIM ...

Using JavaScript to parse Java objects into JSON data

I'm working on sending an array of POJOs as a response to an AJAX call. Within my POJO, the following toString() method is defined: @Override public String toString() { return "Expense [period=" + period + ", description=" + description + ...

The URL is being modified by the Angular $compile function

I have a controller that is working well for dynamically compiling new DOM elements after certain ajax actions: angular.module('cms').controller('CompileHtmlCtrl', [ '$scope', '$compile', function ($scope, $comp ...

What could be causing the slider element to select the incorrect value in Firefox and Internet Explorer?

Attempting to test a slider control on a webpage using Selenium, here is the HTML: <div class="slider theme1 ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all" data-action="Slider" data-step="True" da ...

Retrieving PHP information in an ionic 3 user interface

We are experiencing a problem with displaying data in Ionic 3, as the data is being sourced from PHP REST. Here is my Angular code for retrieving the data: this.auth.displayinformation(this.customer_info.cid).subscribe(takecusinfo => { if(takecusi ...

JavaScript conversion of arrays to JSON data structures

Here is the code snippet along with the variable 'polygon': var directionsDisplay; var directionsService = new google.maps.DirectionsService(); var map; var bermudaTriangle; var directionsPoints; var example; var rez; function initialize() { ...

What could be causing the issue with the theme not functioning properly in Material-UI?

I'm currently working on implementing a unique theme-switching feature in my web application, allowing users to toggle between light and dark modes. Utilizing the Material-UI framework combined with React, here's the code snippet: const theme = c ...

The continuous progression of code execution

Having a background in Java, I decided to dive into learning Angular2 recently and have been working on it. However, I encountered a confusing situation in one of my projects that I could not figure out. For the pagination feature I was implementing, I ne ...

AngularJS Services and Factories that are loaded at startup rather than on-demand

Having an issue with my AngularJS application. I have defined some factories that are injected into controllers as needed. The problem is that these factories are initialized when the application first starts up. One problematic service is: PlanningPoker ...

Using static methods within a static class to achieve method overloading in Typescript

I have a TypeScript static class that converts key-value pairs to strings. The values can be boolean, number, or string, but I want them all to end up as strings with specific implementations. [{ key: "key1", value: false }, { key: "key2&qu ...

Ajax modal login feature refuses to close

Struggling to close a modal login box? Everything seems to be functioning correctly with the modal screen and ajax features, but I'm facing issues when it comes to closing the modal form. The code snippet looks like this: HTML: <a href="#" cla ...

The Keen.io JavaScript API is returning an error code of "UnknownError" even though the event creation was successful

I'm attempting to generate a Keen event from parse.com cloud code (node.js). Utilizing a JS module (https://github.com/roycef/keen-parse) that appears to be properly configured. To validate, I've established a straightforward test and provided th ...