473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

onFocus or focus() issues in Mozilla for Red Hat Linux 8.0?

Hi,

I have Red Hat 8.0 and have the default Mozilla browser that comes with
it. I am programming in javascript and have come across something
problematic. Given the following code:
<HTML>
<HEAD>
</HEAD>
<BODY>
<FORM>
<INPUT TYPE="TEXT" NAME="input1">
<INPUT TYPE="BUTTON" VALUE="Click" onFocus="input2.focus()"
onClick="alert('You clcked me!')">
<INPUT TYPE="TEXT" NAME="input2">
</FORM>
</BODY>
</HTML>

When using MSIE or Netscape for Windows: if you click inside the first
text input and then tab to the button, it will automatically forward focus
to the second text input where you can type text there. This is how I want
it to behave.

But when using Mozilla in RH8.0: when you tab to the button the cursor
appears in the second text input, and so looks like it is working correctly.
But when you try to type something, nothing happens -- the cursor just sits
there blinking. If you then hit the enter key, it will act the same as if
the button has focus (popping up the alert window, since hitting Enter while
a button has focus is the same as clicking the button with the mouse).
So it seems to me that when tabbing to the button, the button is
internally keeping focus even though the event handler is telling it to
forward focus to the second text input and even though the second text input
appears to have focus with the appearance of a cursor.
And the problem isn't only when the element I am trying to skip is a
button. Given the following code:
<HTML>
<HEAD>
</HEAD>
<BODY>
<FORM>
<INPUT TYPE="TEXT" NAME="input1">
<INPUT TYPE="TEXT" NAME="input2" onFocus="input3.focus()">
<INPUT TYPE="TEXT" NAME="input3">
</FORM>
</BODY>
</HTML>

Once again, MSIE and Netscape for Windows handles this properly. But in
Mozilla for RH8.0 when tabbing to the second text input, the cursor appears
there and you can type in the second text input -- it doesn't forward the
focus at all. And worse yet when tabbing from the second text input to the
third text input, the cursor skips the THIRD text input and appears in the
location input at the top of the browser!!!
Furthermore when 'clicking' on the second text input with the mouse, the
text cursor appears in the second text input and stays there but typed text
from the keyboard appears in the third text input.

Does anyone know if these are bugs with that Mozilla (or that version of
it), or does Mozilla have a different event handler or javascript command
that I can give to make it work properly??? The Netscape version on Windows
I am using is 4.0, and I thought Mozilla was created FROM Netscape...

Thanks in advance,
Scott Navarre
Jul 20 '05 #1
4 2373
Scott Navarre wrote:
Hi,

I have Red Hat 8.0 and have the default Mozilla browser that comes with
it. I am programming in javascript and have come across something
problematic. Given the following code:
<HTML>
<HEAD>
</HEAD>
<BODY>
<FORM>
<INPUT TYPE="TEXT" NAME="input1">
<INPUT TYPE="BUTTON" VALUE="Click" onFocus="input2.focus()"
onClick="alert('You clcked me!')">
<INPUT TYPE="TEXT" NAME="input2">
</FORM>
</BODY>
</HTML>


Mozilla doesn't know if you're referring to id 'input2', class 'input2'
or name 'input2'. Use 'document.getElementById(input2).focus()'.
--
Robert Mohr
mo*****@osu.edu
mo***@cis.ohio-state.edu
Jul 20 '05 #2
On Sat, 28 Feb 2004 08:03:25 -0500, Robert Mohr <mo*****@osu.edu> wrote:
Scott Navarre wrote:


[snip]
<FORM>
<INPUT TYPE="TEXT" NAME="input1">
<INPUT TYPE="BUTTON" VALUE="Click" onFocus="input2.focus()"
onClick="alert('You clcked me!')">
<INPUT TYPE="TEXT" NAME="input2">
</FORM>
</BODY>
</HTML>


Mozilla doesn't know if you're referring to id 'input2', class 'input2'
or name 'input2'. Use 'document.getElementById(input2).focus()'.


That wouldn't do much good. Even if you correctly specified the string
literal 'input2' only IE, out of my four browsers, will return a reference
to the third input element.

It should be clear from the name that the getElementById method will only
return a reference to an element with the given id attribute, not a
matching name attribute.

The controls exist within a form, so the simpler approach would be:

onfocus="this.form.input2.focus();"

However, if the sole purpose is to skip a control in the tabbing order,
use the tabindex attribute:

<input ... name="input1" tabindex="1">
<input ... type="button" tabindex="0">
<input ... name="input2" tabindex="2">

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #3
Didn't help -- even if I use 'document.forms[0].elements[2].focus()', it
behaves EXACTLY the same way.
"Robert Mohr" <mo*****@osu.edu> wrote in message
news:c1*********@ripley.netscape.com...
Scott Navarre wrote:
Hi,

I have Red Hat 8.0 and have the default Mozilla browser that comes with it. I am programming in javascript and have come across something
problematic. Given the following code:
<HTML>
<HEAD>
</HEAD>
<BODY>
<FORM>
<INPUT TYPE="TEXT" NAME="input1">
<INPUT TYPE="BUTTON" VALUE="Click" onFocus="input2.focus()"
onClick="alert('You clcked me!')">
<INPUT TYPE="TEXT" NAME="input2">
</FORM>
</BODY>
</HTML>


Mozilla doesn't know if you're referring to id 'input2', class 'input2'
or name 'input2'. Use 'document.getElementById(input2).focus()'.
--
Robert Mohr
mo*****@osu.edu
mo***@cis.ohio-state.edu

Jul 20 '05 #4
Scott Navarre wrote:
But when using Mozilla in RH8.0: when you tab to the button the cursor


so upgrade... your html works fine with current Mozilla. Red Hat 8.0
shipped with Mozilla 1.0.1, which (compared to current builds) was buggy.

--
------------------------------------------------------------------
Andrew Schultz | The views expressed might
aj******@eos.ncsu.edu | not represent those of NCSU.
http://www4.ncsu.edu/~ajschult/ | They are however, correct.
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rich Morey | last post by:
Hello, I have created a form and assigned each of the form elements to a class in a style sheet. I would like to know if it is possible to add 'OnFocus' and 'OnBlur' events to the style sheet...
1
by: Michael Albanese | last post by:
I am developing an application to handle my compay's OSHA reporting requirements. Some of the input criteria are technical and narowly defined, so I was trying to prvide what i call "Context...
2
by: Paresh Shah | last post by:
Hi Friends... I have an query on how to capture onFocus event for all the input controls without writing onFocus event in the <input> tag. say my html form has 3 or 4 or 5 input text boxes,...
2
by: swathi | last post by:
----------------------------------------------------------------------- A poll associated with this post was created, to vote and see th results, please visit...
1
by: Eric Trav | last post by:
Hello, I am using mozilla and javascript to change the style background color for my select with onfocus() and back to white with onblur(). When i process onfocus(); i have to click on the...
8
by: Yeah | last post by:
I wish to use a drop box where each Option will not take the user to a web page - but a certain location on the same page the drop box exists. For example, Option 1 would take the user to "Chapter...
7
by: ukfusion | last post by:
i need a way of changin a class name on focus which works in both ie and mozilla style browsers.....i think i read that className doesnt work in mozilla because its a reserved term or something....is...
2
by: Jonathan N. Little | last post by:
As part of a JavaScript precheck form validation I noticed a problem with trying to return focus to the field with an error. I have setup a demo page. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.