-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
91 lines (70 loc) · 2.02 KB
/
index.html
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Responsive iFrame</title>
<style type="text/css">
html{
height: 100%;
}
body{
padding: 0;
margin: 0;
height: 100%;
}
iframe{
width: 100%;
height: 80%;
border: 0;
width: 70%;
margin-left: 15%;
}
header{
height: 20%;
background-color: #00488b;
}
header h1{
margin:0;
color: #fff;
line-height: 3;
margin-left: 1em;
}
</style>
<script>
function receiveMessage(event) {
var message = event.data.split(':');
var eventName = message[0];
var iframes, len, i = 0;
var senderDomains = ['http://localhost:8000'];
if ( senderDomains.indexOf(event.origin) !== -1 && eventName === 'resize' ) {
iframes = document.getElementsByTagName('iframe');
len = iframes.length;
for (; i < len; i++) {
if ( ( iframes[i].contentWindow || iframes[i].documentWindow ) == event.source) {
iframes[i].style.height = message[1] + "px";
return;
}
}
}
}
if ( window.addEventListener ) {
window.addEventListener('message', receiveMessage, false);
}
else if (window.attachEvent) {
window.attachEvent('onmessage', receiveMessage);
}
</script>
</head>
<body>
<header>
<h1>Super-Awesome-Header</h1>
</header>
<!-- Same Origin iFrame -->
<iframe src="iframe.html" id="responsive-iframe" scrolling="no" frameborder="0"></iframe>
<!--
Cross Origin iFrame
Start server in directory with: python -m SimpleHTTPServer 8000
<iframe src="http://localhost:8000/iframe.html" id="responsive-iframe" scrolling="no" frameborder="0"></iframe>
-->
</body>
</html>