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.
|
|
|
|
|
![]() |
||
Password script needs refining.
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
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. |
|
|
|
||||
|
Re: Password script needs refining.
where are the values coming from? usrnm0.value?
You could try this in your iframe.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: Password script needs refining.
Quote:
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 Wolfy. |
|
||||
|
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)
|
|
|||
|
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 |
![]() |
| Tags |
| basic script, firefox, javascript |
| Thread Tools | |
|
|
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 |