This repository was archived by the owner on Jun 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparent.html
More file actions
45 lines (43 loc) · 2.29 KB
/
Copy pathparent.html
File metadata and controls
45 lines (43 loc) · 2.29 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
<!DOCTYPE html>
<html>
<head>
<title>Splinter</title>
<link rel="shortcut icon" type="image/png" href="https://d3u8ewz6c11pt5.cloudfront.net/static/kshare/0.22/1c2904b8e11a/img/KP_favicon.png" />
<link rel="apple-touch-icon-precomposed" sizes="60x60" type="image/png" href="https://d3u8ewz6c11pt5.cloudfront.net/static/kshare/0.22/1c2904b8e11a/img/Icon-60.png"/>
<link rel="apple-touch-icon-precomposed" sizes="120x120" type="image/png" href="https://d3u8ewz6c11pt5.cloudfront.net/static/kshare/0.22/1c2904b8e11a/img/Icon-60@2x.png"/>
<link rel="apple-touch-icon-precomposed" sizes="180x180" type="image/png" href="https://d3u8ewz6c11pt5.cloudfront.net/static/kshare/0.22/1c2904b8e11a/img/Icon-60@3x.png"/>
<link rel="apple-touch-icon-precomposed" sizes="76x76" type="image/png" href="https://d3u8ewz6c11pt5.cloudfront.net/static/kshare/0.22/1c2904b8e11a/img/Icon-76.png"/>
<link rel="apple-touch-icon-precomposed" sizes="152x152" type="image/png" href="https://d3u8ewz6c11pt5.cloudfront.net/static/kshare/0.22/1c2904b8e11a/img/Icon-76@2x.png"/>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h1>SPLINTER - Parent tab</h1>
<p>Check window.opener to determine if we came from a new tab</p>
<button id="btn-newtab-checkparent" data-endpoint="checkparent">Open New Tab</button>
<p>Try window.close; redirect to URL if timeout</p>
<button id="btn-newtab-tryclose" data-endpoint="tryclose">Open New Tab</button>
<p>Do a window.close and nothing else.</p>
<button id="btn-newtab-forceclose" data-endpoint="forceclose">Open New Tab</button>
<script type="text/javascript">
// name the parent window
window.name = 'kp-parent';
// this doesn't get blocked by popup blockers
function openNewWindow(url) {
var redirectWindow = window.open(url, '_blank');
redirectWindow.location;
}
(function() {
var btns = ['checkparent', 'tryclose', 'forceclose'];
for(var i=0; i<btns.length; i++) {
var btnName = btns[i];
var btn = document.getElementById('btn-newtab-' + btnName);
btn.onclick = function() {
var endpoint = this.dataset.endpoint;
openNewWindow('newtab-' + endpoint + '.html');
};
btn.title = btnName;
}
})();
</script>
</body>
</html>