PDA

View Full Version : Javascript in html


Qwertyuiop23
06-24-2006, 12:59 AM
I am having problems with using my java script and frames. Ihave a login script and i am trying to change it so that it changes just the frame it is. I have that all over document but can't find it in this javascript.

If you need the name it is:
Login name: DarcyFinch
Password: 12345678
The page it goes to: securepg.html

Here is the code:

<center><form name=login>
<table border=1 cellpadding=3>

<!-- Original: Dion -->
<!-- Web Site: http://www.iinet.net.au/~biab/ -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<tr><td colspan=2 align=center><font size="+2"><b>Members-Only Area!</b></font></td></tr>
<tr><td>Username:</td><td><select name=memlist>
<option value='x'>
<option value='DarcyFinch|0|SECUREPG'>DarcyFinch
</select></td></tr>
<tr><td>Password:</td><td><input type=password size=10 maxlength=8 name=pass></td></tr>
<tr><td colspan=2 align=center><input type=button value="Login" onclick="check(this.form)"></td>
</tr>
</table>
</form>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var params=new Array(4);
var alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI";
function check(form) {
which=form.memlist.selectedIndex;
choice = form.memlist.options[which].value+"|";
if (choice=="x|") {
alert("Please Select Your Name From The List");
return;
}
p=0;
for (i=0;i<3;i++) {
a=choice.indexOf("|",p);
params[i]=choice.substring(a,p);
p=a+1;
}
h1=makehash(form.pass.value,3);
h2=makehash(form.pass.value,10)+" ";
if (h1!=params[1]) {
alert("Incorrect Password!"); return; };
var page="";
for (var i=0;i<8;i++) {
letter=params[2].substring(i,i+1)
ul=letter.toUpperCase();
a=alpha.indexOf(ul,0);
a-=(h2.substring(i,i+1)*1);
if (a<0) a+=26;
page+=alpha.substring(a,a+1); };
top.location=page.toLowerCase()+".html";
}
function makehash(pw,mult) {
pass=pw.toUpperCase();
hash=0;
for (i=0;i<8;i++) {
letter=pass.substring(i,i+1);
c=alpha.indexOf(letter,0)+1;
hash=hash*mult+c;
}
return(hash);
}
// End -->
</script>
</center>

If you could help me out that would be great.

_Aerospace_Eng_
06-24-2006, 01:12 AM
Using javascript to password protect a page isn't very secure. JS can be disabled. I think the solution to your problem though might to change this line
top.location=page.toLowerCase()+".html";
to this
parent.frames['name_of_frame'].location=page.toLowerCase()+".html";
where name_of_frame is your frame name

Qwertyuiop23
06-24-2006, 01:13 AM
what do you suggest instead of JS?

_Aerospace_Eng_
06-24-2006, 01:16 AM
Use of a serverside language like php, asp, cgi, jsp, or even htaccess. Is the page only going to be secure just for you or will other people be seeing this page?

Qwertyuiop23
06-24-2006, 01:42 AM
The page that is going to be password protected will be only used by the pople of my company.

_Aerospace_Eng_
06-24-2006, 02:06 AM
Do you intend on using the same password for all the persons in your company?

Qwertyuiop23
06-24-2006, 03:13 AM
Yes i will be doing that

_Aerospace_Eng_
06-24-2006, 03:38 AM
Okay do you know if your webhosts uses Cpanel? If you don't know tell us who your web host is and what hosting plan you have with them.

Qwertyuiop23
06-24-2006, 04:05 AM
I am not too sure as i am creating this for a friend of my dads (no payment) and wouldnt have a clue. www.silage.net.nz is the website if it helps?

_Aerospace_Eng_
06-24-2006, 04:09 AM
Okay do you know if your server supports php? There are many password protect scripts out there already, many of them free. Check out www.hotscripts.com

Qwertyuiop23
06-24-2006, 04:10 AM
Thankyou i don't know PHP i only know html.

_Aerospace_Eng_
06-24-2006, 04:16 AM
Yeah at one point in time thats all I knew as well but there is nothing stopping you from learning php.