Password script needs refining.

This is a discussion on "Password script needs refining." within the JavaScript Forum section. This forum, and the thread "Password script needs refining. are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 3rd, 2007, 12:32
New Member
Join Date: Sep 2007
Location: Earth.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Password script needs refining.

I'm really new to this whole javascript thing, and over the course of my weekend (yes, I'm THAT new!), I've been playing with an idea to password protect a page. I even devised a simple method for doing it:

<script Language="JavaScript">
function lp()
{
newwin = window.open(usrnm0.value + "/" + pswd0.value + ".html")
}
</script>
<form>
<input type=button value="Proceed" onClick="lp()" style="float: right"></td>
</form

It's really simple - if the page with the right values exist, open then. If not, the user will get a 404 not found error. I thought it was quite good.

However, it doesn't work with Firefox, only IE and I don't know enough about it to troubleshoot it. The page with this one is called from an IFrame (which, as a side note, I'd like to have the new page also open up in the frame, rather than in a new window).

Can anyone see where I'm going and what I'm looking for? And where I'm going wrong? Any help would be appreciated.
Reply With Quote

  #2 (permalink)  
Old Sep 3rd, 2007, 16:27
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Password script needs refining.

where are the values coming from? usrnm0.value?

You could try this in your iframe.

Code: Select all
<script type="text/javascript">
 
function lp(formObj) 
{
    var inputs = formObj.getElementsByTagName('input');
 
    parent.location.href = inputs[0].value + '/' + inputs[1].value + '.html';
}
</script>
 
<form>
<input type="text" name="usrnm0" value="" /><br />
<input type="text" name="pswd0" value="" /><br />
<input type="button" value="Proceed" onClick="lp(this.parentNode)" style="float: right"></td>
</form>
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #3 (permalink)  
Old Sep 3rd, 2007, 16:35
New Member
Join Date: Sep 2007
Location: Earth.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Password script needs refining.

Quote:
Originally Posted by Rakuli View Post
where are the values coming from? usrnm0.value?

You could try this in your iframe.

Code: Select all
<script type="text/javascript">
 
function lp(formObj) 
{
    var inputs = formObj.getElementsByTagName('input');
 
    parent.location.href = inputs[0].value + '/' + inputs[1].value + '.html';
}
</script>
 
<form>
<input type="text" name="usrnm0" value="" /><br />
<input type="text" name="pswd0" value="" /><br />
<input type="button" value="Proceed" onClick="lp(this.parentNode)" style="float: right"></td>
</form>
I should have been more specific about what my code was. The user/pass strings are coming out of a form, pretty much as you've written. That, however, has solved the issue.

Not to be pedantic, but being a noob to all of this, and if you have the time, could you briefly explain the difference between your script code and mine? I would appreciate it.

Thank you, in any event for your assistance It's VERY much appreciated.

Wolfy.
Reply With Quote
  #4 (permalink)  
Old Sep 3rd, 2007, 16:51
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Password script needs refining.

No problems.

The way you were referring to the input tags was by name only -- FF and just about all other browsers aren't fans of this.

Instead, what I did was add the variable formObj to the lp() function and then when using the onclick() I added this.parentNode which basically means "This input's firstmost external HTML tag" -- the form in this case.

Inside of the function I can now use the reference to the form (formObj) to get an array of all the inputs inside of it hence formObj.getElementsByTagName('input').

This will return all of the inputs in the order they appear starting from 0.

I changed the winopen to instead refer to the href of the page's parent (parent.location.href) and added the value of the inputs knowing what to use based on their order in your page.

Hope that clears it up a little.

Cheers.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #5 (permalink)  
Old Sep 3rd, 2007, 20:05
New Member
Join Date: Sep 2007
Location: Earth.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Password script needs refining.

Frighteningly, that makes alot of sense and no, I don't mean it sarcastically. I think I've been away from programming for too long<g>


Thank you again I hope this helps someone else.

Reply With Quote
Reply

Tags
basic script, firefox, javascript

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Forgot password and Change password PHP script Chono PHP Forum 4 May 16th, 2008 09:13
PHP Forgot Password script chrizlord PHP Forum 11 May 1st, 2007 00:19
Best script to create users for password protected pages? vandiermen PHP Forum 3 Apr 23rd, 2007 12:22
PHP Forgot password script error eddie PHP Forum 4 Mar 4th, 2007 15:43
Looking for EASY password protect script Lchad PHP Forum 3 Jan 28th, 2007 00:54


All times are GMT. The time now is 05:48.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43