[WEB4LIB] JavaScript Problems: NS 7.0

Robert Tiess rjtiess at warwick.net
Wed Nov 20 18:16:26 EST 2002


Jenifer, here's the problem.  Actually, two problems:

1. If you copied/pasted the code from their web page (http://www.pageresource.com/jscript/jpass.htm) you need to delete the word "hide" from the code: it's not a valid JavaScript command.

2. If you downloaded/modified the example page, which doesn't have the extraneous word "hide" in the code, here's the other problem:  in their code they have a blank space automatically filled in where the user is to enter their information:

   password=prompt('Please enter your password to view this page!',' ');

The last ' ' portion of the above command causes Netscape 4.7x to display a prompt with a space in the input box, which is already highlighted upon display so that when the user types something it overwrites that space.

In Netscape 7/Mozilla 1.0 I noticed that same space in the input box is NOT highlighted, causing the user input to be (to use the website's example) " cool" with a space before "cool" (minus quotes of course).  That is, the user's input is added to the space, not overwriting it.  This will cause a string pattern mismatch, since "cool" does not equal " cool" in the wacky world of computers.

So here's the solution -- change:

   password=prompt('Please enter your password to view this page!',' ');

to

   password=prompt('Please enter your password to view this page!','');

-- just delete the space between the ' ' marks at the end of the prompt command and the routine should work as intended.  Just hope nobody figures out how to view the source code ;-)

I hope this helps.

Robert


Holman Jenifer S wrote:
> We've added a some simple JavaScript code to several pages on our library staff intranet that adds password protection.  The pages work great in Netscape 4.7 and IE5.5 and above, but don't work on either Netscape 6 or 7.  Has anyone else run into problems with JavaScripts not running in later versions of Netscape?  The script itself is from http://www.pageresource.com/jscript/jpass.htm.  This is the first time I've ever run into anything web related working on NS4.7 and not on later versions!
> 
> Jenifer
> 
> p.s.  I know this code is not really providing much security, but it provides the level of peace-of-mind our staff needs.



More information about the Web4lib mailing list