Questions tagged [onfocus]

onfocus is an event in HTML and JavaScript that triggers when the referenced object gains focus. This tag should be used only in conjunction with the primary language tag, and only for questions where the onfocus event is central to the issue(s) being addressed.

The focus event triggers when a visitor focuses on an element.

Not all elements are focusable by default. For example, INPUT and all types or form fields support this event, A supports it. As a counterexample, DIV doesn't support focus.

The list of elements types which support focusing is slightly different between browsers.

Tutorial

498 questions
4
votes
0 answers

(Javascript) window.onblur and window.onfocus not working on android mobile device

I am a beginner in javascript. I am trying to achieve image slider, purely using javascript. For this I am using, setTimeout(function(){ animateSlider(); }, 5000); Where animateSlider() is a function responsible for sliding…
vivek
  • 347
  • 4
  • 9
4
votes
4 answers

Handle blur event of parent element fired by focus on child element and by clicking outside of child

I have a "parent div" containing a child box input type=number. When user clicks outside of input box I use blur or focusout event of parent div to use input values at some other place. I also need to use $('inputbox').trigger('focus') at some…
Umesh K.
  • 311
  • 2
  • 6
  • 14
4
votes
2 answers

Javascript onFocus triggers on page load

Fiddle So I'm having this problem. I have a simple form:
Ivan Chepurin
  • 131
  • 1
  • 2
  • 10
4
votes
1 answer

Key listener to exit loop only when program is on focus (c++)

I wrote a C++ console program that displays a menu with several options for the user, one of them goes into a continuous loop and the condition to exit the loop is !GetAsyncKeyState(VK_ESCAPE). So if a user presses ESC, on the next start of this…
paulovitorjp
  • 538
  • 5
  • 14
4
votes
3 answers

How can I focus an input that's sliding in from off the screen?

I have an element (#cols) that's 3x wider than the . It has 3 columns, each of which is exactly as wide as . Clicking a button slides the #cols element over by the width of one column and simultaneously focuses the in the column…
NudeCanalTroll
  • 2,266
  • 2
  • 19
  • 43
4
votes
1 answer

How to get which image (its position) is on focus in an Image Gallery?

I am playing around with the Gallery widget. I would like to know how can we get the position of the image on focus in the gallery. For example having several pictures in my gallery, if I tap my finger to the right, pictures will come and go until…
Spredzy
  • 4,982
  • 13
  • 53
  • 69
4
votes
1 answer

Android SearchView: What is the difference between setOnFocusChangeListener() and setOnQueryTextFocusChangeListener?

From the reference docs, SearchView.setOnQueryTextFocusChangeListener - Sets a listener to inform when the focus of the query text field changes. and View.setOnFocusChangeListener - Register a callback to be invoked when focus of this view…
Solace
  • 8,612
  • 22
  • 95
  • 183
4
votes
1 answer

Android (Lollipop) EditText onFocus fired multiple times

I have a couple of EditTexts with onFocusChangeListeners // When the field gains or loses focus txtMinimumValue.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { …
FinHead
  • 517
  • 4
  • 12
4
votes
2 answers

Identifying window focus/blur events with iframes

I'm trying to reliably identify when a browser window/tab is activated and deactivated. Normally, window's focus and blur events would do, but the document contains several iframes. When an iframe is focused, the main window gets unfocused and vice…
MCL
  • 3,985
  • 3
  • 27
  • 39
4
votes
4 answers

How to determine when an HTML5 element has been viewed?

I am wondering if there are any HTML5 events associated with whether or not an element has been viewed or "scrolled into view" by the user. An example could be a longer page with elements at the bottom, which has yet to be scrolled into the users…
Bwyan
  • 53
  • 1
  • 6
4
votes
4 answers

focus on second edittext only if first is non-empty android

Currently I have two edit-text,suppose I want to make validation for empty edittext check.What is better way for runtime validation. My code is; final EditText ev1 = (EditText) findViewById(R.id.editText1); final EditText ev2 = (EditText)…
Hanry
  • 5,481
  • 2
  • 40
  • 53
4
votes
3 answers

jQuery - window focus, blur events not triggering - works in Firefox and Chrome

In a nutshell; I wrote a simplistic chat application for a buddy and me to use. When the window running the application does not have the focus (minimized or behind other windows) and a message comes in, I want to change the windows title bar to…
brian newman
  • 3,964
  • 5
  • 25
  • 24
3
votes
0 answers

Android: Spinner does not set selection after edittext had focus

I have a listview of different view types, including spinners and edittexts. I have a single focuslistener that listens for the onfocus lost event as I have to do some post processing. As a user may have to switch from one edittext to a next…
g t
  • 263
  • 1
  • 2
  • 4
3
votes
4 answers

HTML input onfocus and onblur

I am trying to get an input text field to have a thick blue border around it when it is in focus and then to default back to its normal default border when it is no longer in focus. One of my input fields is defined like so:
raphnguyen
  • 3,565
  • 18
  • 56
  • 74
3
votes
2 answers

jQuery Validate resetForm() doesn't reset the onFocus validation

I have a form that is using jQuery Validate plugin for client side validation, and submits via AJAX. After the form is submitted, I would like it to reset itself. I have used the .resetForm() method to reset the fields, which works, but the…
Ryan
  • 17,511
  • 23
  • 63
  • 88