...

View Full Version : Login script with IE referrer solution



charger27
08-14-2008, 09:41 PM
Contents:
Javascript basic login script with username and password (in black).
Simple document.referrer on destination page to prevent direct URL entry and bookmarking.
<body onload="if (document.referrer == '') self.location='my_alternate_page.html';">

Problem:
This works fine in Firefox, however in Internet Explorer - the login returns an empty http referrer, thus being bounced by the document.referrer.
Solution:
The update script (in green) solves the above problem.

The only thing I am struggling with is connecting the update <a href> with the original script's location="".


<script language="javascript">
<!--//
/*This Script allows people to enter by using a form that asks for a
UserID and Password*/
function pasuser(form) {
if (form.id.value=="my_username") {
if (form.pass.value=="my_password") {
location="links to the update script in green"
} else {
alert("Invalid Password")
}
} else { alert("Invalid UserID")
}
}
//-->
</script>
<a href="the_destination_page"
onleftclick="window.open('','newwin','height=1000,width=1024','')"
target="newwin"></a>
<center>
<table bgcolor="white" cellpadding="12" border="1">
<tr><td colspan="2"><center><h1><i><b>Login
Area</b></i></h1></center></td></tr>
<tr><td><h1><i><b>UserID:</b></i></h1></td><td><form name="login"><input
name="id" type="text"></td></tr>
<tr><td><h1><i><b>Password:</b></i></h1></td><td><input name="pass"
type="password"></td></tr>
<tr><td><center><input type="button" value="Login"
onClick="pasuser(this.form)"></center></td><td><center><br><input
type="Reset"></form></td></tr></table></center>


Any help "connecting the dots" would be appreciated.

itsjareds
08-15-2008, 08:39 AM
How about using cookies?

Here's a better replacement for setCookie() and getCookie() - http://techpatterns.com/downloads/javascript_cookies.php

Although I would really recommend using PHP as a login script instead -- javascript is iffy.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum