Skip to content

Instantly share code, notes, and snippets.

@uutarou10
Created July 6, 2018 06:00
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 uutarou10/e85094bedb75371aa581e6e0edabfe07 to your computer and use it in GitHub Desktop.
Save uutarou10/e85094bedb75371aa581e6e0edabfe07 to your computer and use it in GitHub Desktop.
<!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>Document</title>
<script>
function openWindow() {
const win = window.open('./sub.html')
// console.log(win.document.body)
win.addEventListener('load', () => {
const elm = win.document.getElementById('hoge')
elm.innerText = 'hello'
})
}
</script>
</head>
<body>
main window
<button onclick="openWindow()">open sub 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>Document</title>
</head>
<body>
this is sub window
<div id="hoge"></div>
</body>
</html>
@uutarou10
Copy link
Author

DOMContentLoadedでいけたわ
(多分win.document.addEvent...だとうまくいかない)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment