M
mdavis
Hello,
I'm using a Login Control on asp.net 2.0 website and it works fine on
IE & Firefox, however I have recently added a javscript function to
listen for a 'return-key-click' and am encountering problems with
Firefox.
If the user clicks the 'Login' button with a mouse button click, it
works fine, however if the user hits enter, the form fields are
cleared and the user is not logged in.
Please note, this only happens if the user has 'remember passwords'
checked in their Firefox preferences.
Thanks for your time,
Max
//attached javascript:
var objLogin = {
controls : document.getElementsByTagName('input'),
loginButton : null,
userName : null,
password : null,
init : function(){
for (var i=0;i<objLogin.controls.length;i++)
{
if (objLogin.controls.type == 'image')
{
objLogin.loginButton = objLogin.controls;
}
else if
(objLogin.controls.getAttribute('id').indexOf('LoginView1_Login1_UserName')>=0)
{
objLogin.userName = objLogin.controls;
objLogin.addEvent(objLogin.userName, "keydown",
objLogin.setDefault);
}
else if
(objLogin.controls.getAttribute('id').indexOf('LoginView1_Login1_Password')>=0)
{
objLogin.password = objLogin.controls;
objLogin.addEvent(objLogin.password,"keydown",
objLogin.setDefault);
}
else if
(objLogin.controls.getAttribute('id').indexOf('LoginView1_Login1_RememberMe')>=0)
{
objLogin.password = objLogin.controls;
objLogin.addEvent(objLogin.password,"keydown",
objLogin.setDefault);
}
}
},
setDefault : function(e){
if (!e) var e=window.event;
if (e.keyCode == 13)
{
if (e.stopPropagation)
{
e.stopPropagation();
e.preventDefault();
}
else
{
e.returnValue=false;
e.cancel = true;
}
if (objLogin.loginButton!=null)
objLogin.loginButton.click();
}
},
addEvent : function(obj, evType, fn){
if (obj.addEventListener)
{
obj.addEventListener(evType, fn, false);
return true;
}
else if (obj.attachEvent)
{
var r = obj.attachEvent("on"+evType, fn);
return r;
}
else
{
return false;
}
}
}
I'm using a Login Control on asp.net 2.0 website and it works fine on
IE & Firefox, however I have recently added a javscript function to
listen for a 'return-key-click' and am encountering problems with
Firefox.
If the user clicks the 'Login' button with a mouse button click, it
works fine, however if the user hits enter, the form fields are
cleared and the user is not logged in.
Please note, this only happens if the user has 'remember passwords'
checked in their Firefox preferences.
Thanks for your time,
Max
//attached javascript:
var objLogin = {
controls : document.getElementsByTagName('input'),
loginButton : null,
userName : null,
password : null,
init : function(){
for (var i=0;i<objLogin.controls.length;i++)
{
if (objLogin.controls.type == 'image')
{
objLogin.loginButton = objLogin.controls;
}
else if
(objLogin.controls.getAttribute('id').indexOf('LoginView1_Login1_UserName')>=0)
{
objLogin.userName = objLogin.controls;
objLogin.addEvent(objLogin.userName, "keydown",
objLogin.setDefault);
}
else if
(objLogin.controls.getAttribute('id').indexOf('LoginView1_Login1_Password')>=0)
{
objLogin.password = objLogin.controls;
objLogin.addEvent(objLogin.password,"keydown",
objLogin.setDefault);
}
else if
(objLogin.controls.getAttribute('id').indexOf('LoginView1_Login1_RememberMe')>=0)
{
objLogin.password = objLogin.controls;
objLogin.addEvent(objLogin.password,"keydown",
objLogin.setDefault);
}
}
},
setDefault : function(e){
if (!e) var e=window.event;
if (e.keyCode == 13)
{
if (e.stopPropagation)
{
e.stopPropagation();
e.preventDefault();
}
else
{
e.returnValue=false;
e.cancel = true;
}
if (objLogin.loginButton!=null)
objLogin.loginButton.click();
}
},
addEvent : function(obj, evType, fn){
if (obj.addEventListener)
{
obj.addEventListener(evType, fn, false);
return true;
}
else if (obj.attachEvent)
{
var r = obj.attachEvent("on"+evType, fn);
return r;
}
else
{
return false;
}
}
}