How to fix the problem with JavaScript web menu?

In some cases, the password protection may conflict with external JavaScript .js files, especially with a JavaScript based web menu.

Upgrade: In version 4.8, HTML Password Lock added a new "Generate a standalone login file for each locked HTML file" option in Step 3, Advanced Options dialog. With this option, these web pages can be password protected with HTML Password Lock perfectly. For more details, please refer to:

How to password protect HTML page with a FrontPage extension based web form or JavaScript based web menu?

The best way is to remove the JavaScript web menu from the locked HTML file, but if you don't want to do that, there are still three ways to solve this problem.

Solution 1:

To solve the problem, simply move the scripts from the external .js file to the HTML file itself to solve the problem.

For example, a reference to an external .js file in your HTML file may look like this:

<script language="javascript" src="myscript.js"></script>

Please check your HTML file. If it contains such references, please move the JavaScripts from the external .js file to the HTML file itself, then this problem will be fixed.

That is, change the line above to:

<script language="javascript">
(move all scripts here from file "myscript.js")

Solution 2:

If the above method does not fix the problem, you can try fixing it as following:

1. Suppose the HTML that needs for protection is You can create a web page that will automatically redirect to the member page, and lock this web page. The code for this web page might read as shown below, provided you change the filename "" to your own filename. Please DO NOT lock the member.html page.

<script language="JavaScript">
If the page does not redirect automatically, please <a href="">click here</a>

Suppose the new page you created with the above code is login.html. In that case, you need to lock this new file with HTML Password Lock and upload the locked page to your web server as . When your visitor views this page, he will see the login box, after a correct login, he will be automatically redirected to the page, the real member page.

2. The flaw in this solution is that a visitor might try to access directly the member page by typing in the URL address or bookmarking the member page, thus bypassing the password protection. To stop this and force visitors to the login page when they directly type in or bookmark the member page URL, please add the codes shown below to the member page, changing the to your own login filename created in the previous step.

<script language="JavaScript">
function checkvalid()
if (document.cookie.length<0) return false;
if (begin==-1) return false;
if (end==-1) end=document.cookie.length;
if (result=="valid") return true; else return false;
var bRet = checkvalid();
if (!bRet) this.location.href="";

Solution 3:

If the above won't do it, you can use a third method. Remove the JavaScript web menu from the locked page, and embed the locked page to your other web pages with IFRAME.

The following explains how to use IFRAME to embed a locked page.

This is to display a JavaScript based web menu:


This is about how to use IFRAME to embed a locked web page:

Source code:

The file example5.htm is the actual locked page.

Below is the display of example5.htm (username: mtopsoft, password: 123456). It really looks like it's part of the current page, but it isn't. It's just a standalone page named"example5.htm".


HTML Password Lock
Order Now!
  Download Now


Online Help
Quick Start

Online Example

Single Password

Who likes our products:

Rated 4.5 stars at SnapFiles

Pop at Cnet

Rated 5 Stars at The File Transit!

Home | Download | Order Now | Contact us | Links
ęCopyright All Rights Reserved.