Link to home
Start Free TrialLog in
Avatar of Logan
LoganFlag for Spain

asked on

focus/blur mozilla problems

Hi all,

I use the following function without problems in almost any browser (in NS4 does not work, but that is not a problem):

function dF( f, c ){
      var d = window.document.forms[f].elements[c];
      d.blur();
      d.focus();
      if( d.value != "" ){ d.select(); }
}

I call dF in two manners:

1) <body onload="dF('myForm','myField');"> // No problem

2) When current field.maxLength has been reached or enter key is pressed, set focus to next field // Here comes the problems in FireFox

Error: [Exception... "'Permission denied to get property XULElement.selectedIndex' when calling method: [nsIAutoCompletePopup::selectedIndex]"  nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)"  location: "JS frame :: /js/TMP9tegb3qfj3.php :: dF :: line 209"  data: no]
Source File: js/TMP9tegb3qfj3.php Line: 209

Any suggestions?

Thanks in advance
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

The field to be selected is NOT an <input> field. It is a <select> and therefore you cannot call select() on it.
Avatar of Logan

ASKER


That's not the problem Zvonko (but thanks!)

The form is:

<body onLoad="dF( 'pepe', 'dni' )">
<form action="#" method="post" name="pepe" id="pepe">
<input name="cif" type="text" maxlength="9" tabindex="1">
<input name="dni" type="text" maxlength="9" tabindex="2">
<input name="nif" type="text" maxlength="9" tabindex="3" onClick="dF( 'pepe', 'cif' )">
</form>
</body>

As u can see there aren't selects :)
Avatar of Logan

ASKER

btw,

errors are in this lines:

d.blur();
d.focus();
What FireFox version? Because it works in Mozilla1.7.2
Ok, I downloaded Firefox0.9.3 and the strange thing is that the function IS executed even that the exception message occures.
Avatar of Logan

ASKER

yup, thats the matter
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the points.
Avatar of Logan

ASKER

You earned it :)