Javascript Reference - Window blur() Method








The blur() method removes focus from the current window.

Browser Support

blur Yes Yes Yes Yes Yes

Syntax

window.blur()

Parameters

None.

Return Value

No return value.

Example

The following code shows how to remove focus from the new window.


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--   w ww  .  j  a v  a2s .  co  m-->
    var myWindow = window.open("", "", "width=200, height=100");
    myWindow.document.write("<p>A new window!</p>");
    myWindow.blur();
}
</script>

</body>
</html>

The code above is rendered as follows: