blob: 8759362bdf006f09472ca105c02f37115d4f6a15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<script>
window.onmessage = function(e){
if (e.data == "getOrigin") {
parent.postMessage(self.origin, "*");
} else if (e.data == "setDomainAndGetOrigin") {
var oldDomain = document.domain;
try {
document.domain = document.domain.replace(/^[^.]*./, "");
} catch (e) {
parent.postMessage("THREW WHEN SETTING DOMAIN: " + e, "*");
return;
}
if (oldDomain === document.domain) {
parent.postMessage("FAILED TO SET DOMAIN", "*");
} else {
parent.postMessage(self.origin, "*");
}
} else {
parent.postMessage("UNEXPECTED MESSAGE", "*");
}
}
</script>
|