/    Sign up×
Community /Pin to ProfileBookmark

small login script

I am having trouble getting this small login script to work – simply – someone enters a password in the field name ‘ftext’ and the secure webpage opens.
I am getting the If / else statments working fine – but the url doesn’t open.

if replace:

location.href=’http://www.yahoo.com‘;

with

alert(“Good!”);

The function works? How do i get it to open the URL?
I’m a newbie.. any help is appreciated..

<script language = “javascript”>
function Login1()
{
var ftext = document.login.ftext.value;

if(ftext == ‘enter’)
{
location.href=’http://www.yahoo.com‘;
}
else
{
alert(“incorrect password”);
}
}

</script>

<FORM NAME=”login” onSubmit=”return Login1()”>
login: <INPUT TYPE=TEXT NAME=ftext><BR>
<INPUT TYPE=submit VALUE=”Done”>
</FORM>

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Oct 18.2007 — You are probably better off to use window.location.replace() or window.location = ;
Copy linkTweet thisAlerts:
@metalbuckleauthorOct 18.2007 — I actually tried window.location = ; it doesn't work either..

i put in the password 'enter' and it just submits to the form and goes no where...

Actually i looked it this again and i need the URL to open in a popup window..
Copy linkTweet thisAlerts:
@metalbuckleauthorOct 18.2007 — i'm trying this - not working.. :o(

<script language = "javascript">

function Login1()

{

var ftext = document.login.ftext.value;

if(ftext == 'enter')

function popup_window() {

window.open('test.htm', 'popup', 'width=500, height=660, menubar=no, scrollbars=yes, toolbar=no, location=no, resizable=yes, top=, left=');

}

else

{

alert("incorrect password");

}

}

</script>

<FORM NAME="login" onSubmit="return Login1()">

login: <INPUT TYPE=TEXT NAME=ftext><BR>

<INPUT TYPE=submit VALUE="Done">

</FORM>
Copy linkTweet thisAlerts:
@Declan1991Oct 19.2007 — [code=html]
<script language = "javascript">
function popup_window() {
window.open('test.htm', 'popup', 'width=500, height=660, menubar=no, scrollbars=yes, toolbar=no, location=no, resizable=yes, top=, left=');
}
function Login1()
{
var ftext = document.login.ftext.value;

if(ftext == 'enter') {
popup_window();
}
else
{
alert("incorrect password");
}
}

</script>

<FORM NAME="login" onSubmit="return Login1()">
login: <INPUT TYPE=TEXT NAME=ftext><BR>
<INPUT TYPE=submit VALUE="Done">
</FORM>
[/code]

I have a funny feeling that it should be 'menubar="no"' etc. too, but I'm not sure.
Copy linkTweet thisAlerts:
@metalbuckleauthorOct 20.2007 — works perfectly!!! Thank-you...
×

Success!

Help @metalbuckle spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...