让新窗口失去并获得焦点
- <!DOCTYPE html>
- <html>
- <head>
- <script>
- var myWindow;
- function openWin() {
- myWindow = window.open("", "", "width=400, height=200");
- myWindow.blur();
- }
- function blurWin() {
- myWindow.blur();
- }
- function focusWin() {
- myWindow.focus();
- }
- </script>
- </head>
- <body>
- <input type="button" value="打开新窗口" onclick="openWin()">
- <input type="button" value="失焦新窗口" onclick="blurWin()">
- <input type="button" value="聚焦新窗口" onclick="focusWin()">
- </body>
- </html>