Javascript Browser Window blur() Method

Introduction

Click the button to open a new window, and assure that the new window does not get focus.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//from   www.  j  a  v  a2 s  . c  o m
  var myWindow = window.open("", "", "width=200, height=100");
  myWindow.document.write("<p>A new window!</p>");
  myWindow.blur();
}
</script>

</body>
</html>

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

Use the focus() method to set focus to the current window.

window.blur();



PreviousNext

Related