Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Last active June 18, 2018 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nolanlawson/164ddb177247d0963a7a5e21554e5e58 to your computer and use it in GitHub Desktop.
Save nolanlawson/164ddb177247d0963a7a5e21554e5e58 to your computer and use it in GitHub Desktop.
Test window.focus() on child window
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Test window.open focus</title>
<style>
body {
max-width: 600px;
margin: 20px auto;
}
</style>
</head>
<body>
<h1>Test window.open focus</h1>
<button type="button" onclick="window.__window = window.open('window.html');">Open window</button>
<button type="button" onclick="window.__window.focus()">Focus window</button>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Test window.open focus</title>
<style>
body {
max-width: 600px;
margin: 20px auto;
}
</style>
</head>
<body>
<h1>Test window.open focus</h1>
<p>Switch back to the other tab and click "focus window"</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment