Window Open – Focus and Blur

[Total: 0    Average: 0/5]

This shows how to create a new window and have the current window “hide” the new window by focus() on itself.

Body Code:

<script type=text/javascript>
var x = null;
function doIt1() {
  x = window.open("http://www.js-examples.com/js/");
  window.focus();
}
function doIt2() {
  x.focus();
}
function doIt3() {
  window.blur();
}
function doIt4() {
  window.focus();
}
</script>
<BR><a href="javascript:doIt1()">open new window and have this one focus()</a>
<BR><a href="javascript:doIt2()">focus new window</a>
<BR><a href="javascript:doIt4()">focus this window</a>
<BR><a href="javascript:doIt3()">blur this window</a>

Times Viewed: 4

Leave a Reply

Your email address will not be published. Required fields are marked *