Add a password to a button's OnMouseDown

  • Thread starter Thread starter JNariss
  • Start date Start date
J

JNariss

Hello,

I have created an Intranet for my company and was trying to figure out
if I can add a password to a button on my webpage. Well........I know I
can the question now is how???

I want to add the password to this code (the code for my button):

<p>
<a href="Overnight%20Parking.doc">
<img border="0" id="img20" src="../Buttons/button353.jpg" height="33"
width="165" alt="Overnight Parking"
onmouseover="FP_swapImg(1,0,/*id*/'img20',/*url*/'../Buttons/button354.jpg')"
onmouseout="FP_swapImg(0,0,/*id*/'img20',/*url*/'../Buttons/button353.jpg')"
onmousedown="FP_swapImg(1,0,/*id*/'img20',/*url*/'../Buttons/button355.jpg')"
onmouseup="FP_swapImg(0,0,/*id*/'img20',/*url*/'../Buttons/button354.jpg')"
fp-style="fp-btn: Glass Rectangle 3" fp-title="Overnight
Parking"></a></p></div>
<p>


I figure it will have to be somehow implemented into the onmousedown,
however I am unsure of how to do this.

I have a simple password code that works when added to the beginning of
my html code for when a page is opened, which is:

<SCRIPT language="JavaScript">
<!--hide

var password;

var pass1="cool";

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

if (password==pass1)
alert('Password Correct! Click OK to enter!');
else
{
window.location="http://www.pageresource.com/jscript/jpass.htm";
}

//-->
</SCRIPT>


I also found this code within the search groups:

<!-- Begin


function click() {
if (event.button==2) {
alert('Sorry, on the login page you cannot right-click. This is for
security reasons.');


}
}


document.onmousedown=click

function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="user1" && password=="pass1") {
window.location="logged.htm"; done=1; }
if (username=="user2" && password=="pass2") {
window.location="logged.html"; done=1; }
if (username=="user3" && password=="pass3") {
window.location="logged.html"; done=1; }
if (username=="user4" && password=="pass4") {
window.location="logged.html"; done=1; }
if (done==0) { alert(" Login failure. Try again. "); }


//The following are the greetings for each user


if (username=="user1" && password=="pass1") { alert(" Hello User1!
"); }
if (username=="user2" && password=="pass2") { alert(" Hello user2!
"); }
if (username=="user3" && password=="pass3") { alert(" Hello user3!
"); }
if (username=="user4" && password=="pass4") { alert(" Hello user4!
"); }



}


// End -->



But I have no idea where to enter the code into the current html code.
If anyone could help me with this I would greatly appreciate it. Unless
someone has a better idea that will work too.

Thanks,
Justine
 
Secure password protection requires server side scripting or the use
of subwebs (if your host supports subwebs with unique permissions.
See
Password Protect Part of a Web:
http://support.microsoft.com/default.aspx?scid=kb;en-us;301554

Protect individual pages:
http://support.microsoft.com/default.aspx?scid=kb;en-us;825498


If you must use JavaScript for security, the script you have is
useless - the password is in the script for all to see with View
Source - and try it with JavaScript turned off. A better method of
using JavaScript is at www.rxs-enterprises.org/tests/jspass/, which
fails gracefully with no JavaScript, but is still not secure.

In the fist two methods, the Interactive Button should be simply
linked to the secured page - the login dialogue will appear
automatically. In the third case, the button links to Login page.
 
Wow........this is great info. Thanks Ron. I can't even believe I did
not think about viewing the source code and revealing the password for
all to see!!!!! I will read up on the articles you have supplied me
with and implement another idea.

Thanks Again.
 
Back
Top