Permalink
Browse files

Cookie-detect example didn't work in IE8

  • Loading branch information...
1 parent 8aff34c commit 1d3797c821100678bcd316da2959d837df12e9d5 @benvinegar committed Mar 25, 2012
@@ -11,7 +11,8 @@
}
return false;
}
- window.parent.postMessage(testCanWriteCookies(), '{{ publisher_url }}');
+
+ window.parent.postMessage(JSON.stringify(testCanWriteCookies()), '{{ publisher_url }}');
</script>
</head>
</html>
@@ -29,10 +29,15 @@
var target = document.getElementsByTagName('script')[0];
target.parentNode.insertBefore(iframe, target);
- window.onmessage = function(e) {
- var id = e.data ? 'enabled' : 'disabled';
+ function onmessage(e) {
+ var id = JSON.parse(e.data) ? 'enabled' : 'disabled';
document.getElementById(id).style.display = 'block';
}
+
+ if (window.attachEvent)
+ window.attachEvent('onmessage', onmessage);
+ else
+ window.addEventListener('message', onmessage, false);
})();
</script>

0 comments on commit 1d3797c

Please sign in to comment.