469,568 Members | 1,498 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,568 developers. It's quick & easy.

Login Control problems in Firefox

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[i].type == 'image')
{
objLogin.loginButton = objLogin.controls[i];
}
else if
(objLogin.controls[i].getAttribute('id').indexOf('LoginView1_Login1_Use rName')>=0)
{
objLogin.userName = objLogin.controls[i];
objLogin.addEvent(objLogin.userName, "keydown",
objLogin.setDefault);
}
else if
(objLogin.controls[i].getAttribute('id').indexOf('LoginView1_Login1_Pas sword')>=0)
{
objLogin.password = objLogin.controls[i];
objLogin.addEvent(objLogin.password,"keydown",
objLogin.setDefault);
}
else if
(objLogin.controls[i].getAttribute('id').indexOf('LoginView1_Login1_Rem emberMe')>=0)
{
objLogin.password = objLogin.controls[i];
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;
}
}
}

Mar 1 '07 #1
2 1674
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)

md****@medelect.co.uk wrote:
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[i].type == 'image')
{
objLogin.loginButton = objLogin.controls[i];
}
else if
(objLogin.controls[i].getAttribute('id').indexOf('LoginView1_Login1_Use rName')>=0)
{
objLogin.userName = objLogin.controls[i];
objLogin.addEvent(objLogin.userName, "keydown",
objLogin.setDefault);
}
else if
(objLogin.controls[i].getAttribute('id').indexOf('LoginView1_Login1_Pas sword')>=0)
{
objLogin.password = objLogin.controls[i];
objLogin.addEvent(objLogin.password,"keydown",
objLogin.setDefault);
}
else if
(objLogin.controls[i].getAttribute('id').indexOf('LoginView1_Login1_Rem emberMe')>=0)
{
objLogin.password = objLogin.controls[i];
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;
}
}
}
Mar 1 '07 #2
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" <no****@nospam.comwrote in message
news:e%****************@TK2MSFTNGP03.phx.gbl...
>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)

md****@medelect.co.uk wrote:
>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[i].type == 'image')
{
objLogin.loginButton = objLogin.controls[i];
}
else if
(objLogin.controls[i].getAttribute('id').indexOf('LoginView1_Login1_Use rName')>=0)
{
objLogin.userName = objLogin.controls[i];
objLogin.addEvent(objLogin.userName, "keydown",
objLogin.setDefault);
}
else if
(objLogin.controls[i].getAttribute('id').indexOf('LoginView1_Login1_Pas sword')>=0)
{
objLogin.password = objLogin.controls[i];
objLogin.addEvent(objLogin.password,"keydown",
objLogin.setDefault);
}
else if
(objLogin.controls[i].getAttribute('id').indexOf('LoginView1_Login1_Rem emberMe')>=0)
{
objLogin.password = objLogin.controls[i];
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;
}
}
}

Mar 2 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Ghazan Haider | last post: by
reply views Thread by Steve Commisso | last post: by
3 posts views Thread by goot | last post: by
2 posts views Thread by =?Utf-8?B?U2hhbm5vbg==?= | last post: by
2 posts views Thread by SF | last post: by
10 posts views Thread by DavidPr | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.