This repository was archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathiframe-test.html
More file actions
55 lines (51 loc) · 1.37 KB
/
iframe-test.html
File metadata and controls
55 lines (51 loc) · 1.37 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta name="viewport" content="initial-scale=1.0">
<style>
html {
height: 100%;
}
body {
margin: 0;
height: 100%;
overflow: hidden;
}
.header {
background-color: #4d8618;
height: 70px;
}
iframe {
width: 100%;
min-height: 100%;
border: none;
padding-bottom: 50px;
}
</style>
</head>
<body>
<div class="header"></div>
<iframe src="../index.html"></iframe>
<script>
(function() {
var iframe = document.getElementsByTagName('iframe')[0];
var iframeWindow = iframe.contentWindow;
window.addEventListener('hashchange', function() {
iframeWindow.postMessage({
type: 'hashchange',
hash: window.location.hash
}, '*');
});
window.addEventListener('message', function(e) {
window.location.hash = e.data.hash;
});
iframe.onload = function() {
iframeWindow.postMessage({
type: 'init',
hash: window.location.hash
}, '*');
};
})();
</script>
</body>
</html>