-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
33 lines (26 loc) · 1.06 KB
/
index.html
File metadata and controls
33 lines (26 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Фреймы</title>
</head>
<body>
<p id="content">Контент страницы</p>
<iframe id="myFrame" src="menu.html" name="MENU"> </iframe>
<p id="reply">Поле для ответа фрейма</p>
<script>
document.addEventListener('DOMContentLoaded', function() {
const content = document.querySelector('#content')
content.addEventListener('click', menuEvent);
myFrame = document.querySelector('#myFrame')
function menuEvent(event) {
myFrame.contentWindow.postMessage('Данные, которые мы хотим отправить', '*');
console.log('Отправлено сообщение в фрейм')
}
window.onmessage = function(event) {
document.querySelector('#reply').textContent = event.data
}
})
</script>
</body>
</html>