Login Control problems in Firefox

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;
}
}
}
 
B

bruce barker

i don't see anything obvious, but you are canceling the current event
and firing a new one. i change:

objLogin.loginButton.click();

to
window.setTimeout(function(){objLogin.loginButton.click();});

also asp.net has a built set default button function you could use
instead (see panel).

-- bruce (sqlwork.com)
 
A

alf

Hi, I would like to force postback when retunr key is pressed but I don't
found the property to do this.
What you mean about "see panel" ??
thanks.

bruce barker said:
i don't see anything obvious, but you are canceling the current event and
firing a new one. i change:

objLogin.loginButton.click();

to
window.setTimeout(function(){objLogin.loginButton.click();});

also asp.net has a built set default button function you could use instead
(see panel).

-- bruce (sqlwork.com)

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;
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top