JavaScript window.focus() Method
You are Here:
JavaScript window.focus() Method
The window.focus()
method makes a request to bring the specified window to the front.
Note: The window isn't guaranteed to be frontmost before this method returns.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<button onclick="myOpen()">Open Window</button>
<button onclick="myFocus()">Focus Window</button>
<button onclick="myBlur()">Blur Window</button>
<script>
var myWindow;
function myOpen() {
myWindow = window.open("", "myWindow", "width=400, height=200");
}
function myFocus(){
myWindow.focus();
}
function myBlur(){
myWindow.blur();
}
</script>
</body>
</html>
Syntax
window.focus()
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.