forked from tomyun/xeit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink.js
34 lines (29 loc) · 957 Bytes
/
link.js
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
(function () {
var xeit = document.getElementById('xeit');
if (xeit) {
return;
}
var attachment = document.getElementsByTagName('html')[0].outerHTML;
var _body = document.body;
document.body = document.createElement('body');
document.body.style.margin = 0;
document.body.style.padding = 0;
document.body.style.height = '100%';
xeit = document.createElement('iframe');
xeit.setAttribute('id', 'xeit');
xeit.setAttribute('src', 'http://tomyun.github.io/xeit/xeit.html');
xeit.style.width = '100%';
xeit.style.height = '100%';
xeit.style.border = 0;
document.body.appendChild(xeit);
window.addEventListener('message', function (e) {
switch (e.data) {
case 'ready':
xeit.contentWindow.postMessage(attachment, '*');
break;
case 'fallback':
document.body = _body;
break;
}
}, false);
})();