Gets the object that has the focus when the parent document has focus. If no element in the document has focus, returns the <body> element.
Property of dom/Documentdom/Document
SyntaxNote: This property is read-only.
var element = document.activeElement;
Return Value
Returns an object of type DOM NodeDOM Node
The currently active element of the document, or <body>
if no element is active.
function getActiveElement () {
if (document.activeElement) {
alert(document.activeElement.tagName);
}
}
Notes
The active element retains focus in the parent Document even when focus is shifted from the parent to another application. If the focus returns to the parent document, focus also returns to the same active element.
Related specificationsMicrosoft Developer Network: [Windows Internet Explorer API reference Article]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4