Every line of 'javascript get focused element' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
357 private getCurrentFocusedElement(): HTMLElement | null { 358 return document.getElementById(this.getCellId(this.selection.row, this.selection.column, this.selection.key)); 359 }
23 export function focusInput(element) { 24 if (!element) return; 25 26 const textNode = findLastTextNode(element); 27 if (textNode) { 28 const range = document.createRange(); 29 range.setStart(textNode, textNode.length); 30 range.collapse(true); 31 32 const selection = window.getSelection(); 33 selection.removeAllRanges(); 34 selection.addRange(range); 35 } 36 37 element.focus(); 38 }
21 function getFocus() { 22 var inFocus; 23 24 try { 25 inFocus = document.hasFocus(); 26 } catch(e){} // eslint-disable-line no-empty 27 28 if (typeof inFocus !== "boolean") { 29 // Assume we are 30 return true; 31 } 32 33 return inFocus; 34 }
136 function focusEnd() 137 { 138 $("#input").focus(); 139 var editableDiv = document.getElementById("input"); 140 cursorManager.setEndOfContenteditable(editableDiv); 141 }
23 function focusInInput(e) { 24 return ( 25 /input|textarea/i.test(e.target.tagName) || e.target.getAttribute('contenteditable') !== null 26 ); 27 }
575 function get_Focused () { 576 return JSIL.Host.isPageVisible(); 577 }
1553 _onFocus(event, element) { 1554 // NOTE(mmalerba): We currently set the classes based on the focus origin of the most recent 1555 // focus event affecting the monitored element. If we want to use the origin of the first event 1556 // instead we should check for the cdk-focused class here and return if the element already has 1557 // it. (This only matters for elements that have includesChildren = true). 1558 // If we are not counting child-element-focus as focused, make sure that the event target is the 1559 // monitored element itself. 1560 const /** @type {?} */ elementInfo = this._elementInfo.get(element); 1561 if (!elementInfo || (!elementInfo.checkChildren && element !== event.target)) { 1562 return; 1563 } 1564 // If we couldn't detect a cause for the focus event, it's due to one of three reasons: 1565 // 1) The window has just regained focus, in which case we want to restore the focused state of 1566 // the element from before the window blurred. 1567 // 2) It was caused by a touch event, in which case we mark the origin as 'touch'. 1568 // 3) The element was programmatically focused, in which case we should mark the origin as 1569 // 'program'. 1570 if (!this._origin) { 1571 if (this._windowFocused && this._lastFocusOrigin) { 1572 this._origin = this._lastFocusOrigin; 1573 } 1574 else if (this._wasCausedByTouch(event)) { 1575 this._origin = 'touch'; 1576 } 1577 else { 1578 this._origin = 'program'; 1579 } 1580 } 1581 this._setClasses(element, this._origin); 1582 elementInfo.subject.next(this._origin); 1583 this._lastFocusOrigin = this._origin; 1584 this._origin = null; 1585 }
240 function isFocused() { 241 return document.activeElement === text; 242 };
55 isFocused() { 56 return focused === this; 57 }
504 get focused() { 505 return this._focused || false; 506 }