Using the password script below results in a password field popping up when accessing the page where the code is added. Anyone accessing the page must enter the correct password to access the protected page or content.
Example
View the example page to see how the script functions. This script encounters issues if placed on the same page as the destination page (such as we have done on this page). When implementing, we recommend you place this code on a page of its own and direct users that enter the correct password to another page. It is also best to add this code in the HTML
tag.Source code
This suggestion is not a recommended method for sites that need to be 100% secure, as a more experienced user can easily bypass this method of password protecting a web page.
If you are looking for a more secure method of implementing passwords, you need to create a .htaccess file on the server containing the security information. If supported, additional information on how to do this is available through your ISP or web host.
Related information
- See our JavaScript definition for further information and related links on this term.