PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Written By
Views

How to password PROTECT 🔒 your website using JAVASCRIPT!

How to password PROTECT 🔒 your website using JAVASCRIPT!

These scripts are very simple javascript. They are the first line to protect privacy of webpages. Someone who can access the HTML page source code can easily find the username and password and enter the page. Anyone with a little idea about HTML and computers can see the source code.


The Script

The javascript displays a form to enter the Username and Password. If either is wrong, it will display and alert screen like ‘Wrong Username’ or ‘Wrong Password’.

The username is set to ‘SECRET_USER‘ and the password is ‘SECRET_PASSWORD‘ – both can be set as you like. If both are right, then you are taken to the next URL, which is currently set to this YOURDOMAIN.com.

<SCRIPT language="JavaScript">
var password; 
var pass1="SECRET_PASSWORD"; 
password=prompt('Enter Password',' '); 
if (password==pass1) 
alert('Correct Password! Click OK to Enter!'); 
else { window.location="http://YOURDOMAIN.com/"; 
} 
</SCRIPT>

To change the password change look at line 4 and change pass1 to whatever password!

Live Demo (Thanks to AWS Amplify): https://master.d37ksplxa972bh.amplifyapp.com The password is pass1.

Also here is a video demo.

Comments (0)

loading comments