PDA

View Full Version : Solved: FP2000-pw page keeps opeing new window



MoosePuck
08-15-2004, 05:36 AM
I am not sure if this is the correct forum to ask this question (feeling like I don't know enough to know what I don't know, ya know?)

I have built a site in Front Page 2000 using frames (banner/nav/main (contents)

I am trying to use a javascript to ask a user for a password to enter a protected Page.

Currently all pages sit at the root.

This is my problem:

When I enter the password, it is opening the page in a new window, which I don't want. I want it to open in the 'main' frame.

I have my Header on all content pages set to <base target="main">

The button to click to enter the password is contained within a form and the form porperties are also set to target the main frame.

This is the js I am using:

<SCRIPT>
function passWord() {
var testV = 1;
var pass1 = prompt('Please Enter Your Password',' ');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1.toLowerCase() == "hello") {
;
window.open('thatpage.htm');
break;
}
testV+=1;
var pass1 =
prompt('Password Incorrect, Please Try Again - or contact us at 1-555-555-1212.','Password');
}
if (pass1.toLowerCase()!="password" & testV ==3)
history.go(-1);
return " ";
}
</SCRIPT>

I am not sure where else to look or where to go from here. Can you help?

thank you

smozgur
08-15-2004, 11:13 AM
Hi MoosePuck,

For your question try this: use window.location instead window.open

Change following line:

window.open('thatpage.htm');

to this

window.location = 'thatpage.htm';


However, I'd like to say this is not very good way to protect a page, because people can open that page by just entering the page name in the URL instead entering the password (page url is viewable in HTML code, you know).

For better protection, I can suggest an ASP or PHP (which one is possible in your server) application that would easily check out the entered password and return the necessary HTML code to display or not if pwd is wrong.

By the way, may be you already know all what I meant above and just wanted to use this way, so please ignore my protection comment above.

Suat

MoosePuck
08-15-2004, 11:20 AM
Thank you very much smozgur! :thumb

That did work

Yes I know it is not very secure:o: , but I am just doing a 'dummy' right now to give some eye candy.

I just worked with the host today and can now use their secure folders and will apply that when the site goes live.
I don't know anything about ASP so it will be a challenge for me. I have a lot of reading to do!
I will need to use this "ASP" for a form too. (have to enter info before you can download) We shall see if I have any hair left at the end of the week :roll:

smozgur
08-16-2004, 04:11 AM
Glad to hear it helps, MoosePuck!

Suat

PS: I wrote a simple ASP script for you, for this protection. It might help you while you are learning ASP. You can use this script by saving it as an asp file (test.asp for example).


<%
'The thing is:
'ASP applications create the HTML code and send to client browser
'The advantage is :
'we can control sent data by forms and create the HTML codes according to user entries

'In this sample ASP code
'we are checking user entry - password
'if password is correct then we have ASP code to create protected page code
'else return to Login Page


'We are checking if user sent the form
'by entering password
if Request.Form("pwd")="" then
'If form's pwd field is empty
'then we have no password to verify
'Call login page
strhtml = LoginPage(false)
else
'if form's pwd field has a value
'then it means we have a password to verify
if Request.Form("pwd")="password" then
'If password is correct
'then call protected page creator function
strhtml = ProtectedPage()
else
'If password is incorrect
'then call login page with "Wrong Password!!!" warning
'boolean parameter = true : means to put warning
strhtml = LoginPage(true)
end if
end if
'Send the created html code to the client explorer window
Response.Write strhtml


'Login page function
function LoginPage(WrongPassword)

LoginPage = "<html> " & _
"<body>" & _
"<form name=pwdform method=post>"

'If boolean parameter is true
'then we have a wrong password entered
'we should warn user
if WrongPassword then
LoginPage = LoginPage & _
"<B>Wrong Password!!!</B><BR>"
end if

LoginPage = LoginPage & _
"<input type=password name=pwd>" & _
"<input type=submit name=submit value=Login>" & _
"</form>" & _
"</body>" & _
"</html>"
end function

'Protected page function
function ProtectedPage()
'This function creates the HTML code
'for the protected page
ProtectedPage = "<html> " & _
"<body>" & _
"This is the password protected page." & _
"</body>" & _
"</html>"
end function
%>

MoosePuck
08-16-2004, 04:18 AM
Thank You! :kiss

This is just WONDERFUL!
I now know what I don't know and you have sent me well on my way to knowing! LOL . I am very happy!
:bigdance2

How fantantastic of you to go to this length for me!! :ipray:
I sure hope there is a day where you can receive this kindness back from me :super:

I am going to use your example today and take over the asp world!

all the best to you
Irene

smozgur
08-16-2004, 04:24 AM
You're welcome, Irene!

I believe it would be easier once you get a start point. And I'd be most happy if this little start helps you.

Suat

MoosePuck
08-16-2004, 04:52 AM
It surely does!!!

I am editing/updating a current site and there was an asp file in there. I had no idea what to do with it. Now I know I can open it up in Text and edit it!
Yay!!!!

I have one final question if you don't mind (just in case I run into errors that make me scratch my head)

Can you use JavaScript and VBS on the same page?
The reason I ask. I use FrontPage2000 and in the setup (Web Options, Defualt Script Language) it asks you if you are using JS or VBS.

Again, thank you so much

smozgur
08-16-2004, 05:00 AM
Can you use JavaScript and VBS on the same page?

It is possible to use both in same page when you specify the language that you are using in SCRIPT tag.

<html>
<body>
<script language=VBScript>
msgbox "This one is VBScript"
</script>
<script language=JScript>
alert ("This one is JScript") ;
</script>
</form>
</body>
</html>

I believe using only JScript will be enough in HTML pages.

The VBScript in ASP will already not work at client side, only work in Server to produce the response. ASP code won't be seem at client side but only returned HTML code.

Suat

MoosePuck
08-16-2004, 05:06 AM
Huge grins

thank you!!

I will work on this today and privately publish to the live site and see what happens. I noticed that testing it on my desktop does not display as expected, and I believe I am understanding that the server needs to be involved. (the live asp works and, now with the knowledge you have given to me, I am just editing the page layout)

This sure is making my learning an enjoyable experience.

off to work

Thanks Again!

Irene