-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathindex_iframe.html
77 lines (68 loc) · 2.58 KB
/
index_iframe.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
<!DOCTYPE html>
<html>
<head>
<title>Gamedistribution.com HTML5 Self-Hosted Game Wrapper</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<style>
html {
height: 100%;
}
body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
#container {
position: absolute;
top: 0;
left: 0;
width: 0;
height: 0;
overflow: hidden;
max-width: 100%;
max-height: 100%;
min-width: 100%;
min-height: 100%;
box-sizing: border-box;
}
</style>
</head>
<body>
<iframe id="container" frameborder="0" allow="autoplay" allowfullscreen seamless="seamless" scrolling="no"></iframe>
<script type="application/javascript">
function getRequestParameters(url) {
var res = {};
var index = url.indexOf("?");
if (index !== -1) {
var query = url.substr(index + 1); // Drop the leading '?' / '#'
var nameValues = query.split("&");
for (var i = 0; i < nameValues.length; i++) {
var nameValue = nameValues[i].split("=");
var name = nameValue[0];
var value = nameValue[1];
value = decodeURIComponent(value.replace(/\+/g, " "));
res[name] = value;
}
}
return res;
}
function getReferrerUrl() {
var parentUrl = document.location.href;
if (window.location !== window.parent.location && document.referrer) {
parentUrl = document.referrer;
}
if (document.referrer.indexOf('localhost') !== -1) {
parentUrl = 'https://gamedistribution.com/';
}
var params = getRequestParameters(parentUrl);
return params.gd_sdk_referrer_url || parentUrl;
}
// Add the self-hosted game url as value of gameUrl.
var gameUrl = 'http://example.io';
document
.getElementById('container')
.src = gameUrl + '?gd_sdk_referrer_url=' + getReferrerUrl();
</script>
</body>
</html>