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
6
votes
1 answer

How to detect EditText got focus by Android. Not by end-user touching on the edit text?

An android.widget.EditText can get focus by 2 reasons as I know: Case 1. End-users touch on the edit text by purpose. Case 2. The system give the Edit Text automatically. Navigation First default focus ... My question is: How to I detect Case 2…
LHA
  • 9,398
  • 8
  • 46
  • 85
6
votes
4 answers

How to use Firebug when debugging Javascript entailing focus/blur event handling

I'm trying to use Firebug to debug some Javascript that entails blur and focus event handling, specifically some auto-complete/look-ahead functionality. The issue is that, merely by clicking on the various tabs within Firebug, such as "Console",…
Dexygen
  • 12,287
  • 13
  • 80
  • 147
5
votes
6 answers

CSS: How make the cursor to become a pointer on the input file?

How can I make the cursor to become a pointer on an input file or an input text when you hover it? My try but it does not work of course, Or do I have to use javascrip (jquery)?? EDIT: Sorry my mistake…
Run
  • 54,938
  • 169
  • 450
  • 748
5
votes
4 answers

window onload and window onfocus

window.onload = function() { window.onfocus = alert('example'); } I've met this problem, anyone can help? I'm new at javascript and made this expecting to work properly, but it does not :) I want to alert the word "example" when the page is fully…
Henrikh
  • 150
  • 2
  • 3
  • 11
5
votes
6 answers

Angular 7 | HostListener blur conditional stop all other event callbacks

I have one requirement where We want the user to resolve input field errors and until that is done user is not allowed to do any other operation on-screen. For the same, I have implemented HostListener on the input field and onBlur I am setting the…
Manish Kumar
  • 1,131
  • 15
  • 28
5
votes
9 answers

Clear TEXTAREA value after click (onFocus)

I'm currently using.. onfocus="this.value=''; return false;" to clear the value within my textarea for leaving comments. However, when you click to enter a comment and type a few things, if you were to click outside the box to maybe read something…
Jeff
  • 81
  • 1
  • 1
  • 3
5
votes
1 answer

Use onFocus on a div with React and Typescript

I can not figure out how to use the Focus event with React and Typescript: private onFocus(event: FocusEvent) { } ...
Element
With the code above I get the following error Types of property…
Nicolas
  • 2,191
  • 3
  • 29
  • 49
5
votes
1 answer

Show all options of datalist on focus

Is there any way to show all options of datalist on focus? I need to show all the options even after a key press.
Fasna
  • 564
  • 1
  • 10
  • 28
5
votes
4 answers

Change an element's onfocus handler with Javascript?

I have a form that has default values describing what should go into the field (replacing a label). When the user focuses a field this function is called: function clear_input(element) { element.value = ""; element.onfocus = null; } The…
Logan Serman
5
votes
1 answer

How to select all text in a WPF TextBox when focused from codebehind?

I would like to set the focus of a WPF TextBox from codebehind (not the TextBox's codebehind, but some parent control) and select all text in the TextBox from the TextBoxs codebehind when it receives that focus. I focus the TextBox like this: var…
Marc
  • 12,706
  • 7
  • 61
  • 97
4
votes
4 answers

Global function calls by tag possible?

I have many instances similar to the following in my source code: Every input tag…
Michael Swarts
  • 3,813
  • 8
  • 31
  • 41
4
votes
1 answer

How to focus a WPF tab item when tab item content is selected?

I have an application whose user interface is made up of a tab control. Each tab item is bound to a view model that has a IsFocused property. It is set correctly when the tab item header gains or loses focus. This works as expected. However, I want…
dezzy
  • 479
  • 6
  • 18
4
votes
3 answers

How to make jQuery autocomplete list display all options onfocus and hide after option is selected?

I have a form with an autocomplete that starts the search "onfocus" and shows the option list when the user clicks into the search field, even when they do not enter anything. The problem is the autocomplete requires the option to be selected with…
Michael
  • 2,276
  • 15
  • 49
  • 80
4
votes
1 answer

ReactJS - Clear select value on focus

I need to clear the selected value of select dropdown as soon as user focus on the select element. I have used the below code but cant figure out what property of select do I need to reset. s. onBlur fires every time user clicks on one of the s. This is a bit frustrating that onBlur happens when I hit something inside the div. After an hour of searching I still wasn't able to find…
dmigo
  • 2,849
  • 4
  • 41
  • 62
1 2
3
33 34