I would like to detect when Prevent Cross-site tracking is active in a browser using JavaScript.
My challenge is trying to find a method to detect this and show a warning popup to the user when this cross-site tracking is disabled by a users browser. This became essential after Safari 13 disabled it as default. I believe this might be helpful for people who are using cookies on iframes.
There are some ways such as
Check if third-party cookies are enabled
and
https://gist.github.com/iansltx/18caf551baaa60b79206
which are trying to bypass this security feature with using different methods and some of them are not valid anymore.
Basically what I try to achieve is from an iframe, try to detect Prevent Cross-site tracking is enabled on the browser using JavaScript.
I tried using this code:
var receiveMessage = function (evt) {
if (evt.data === 'MM:3PCunsupported') {
document.getElementById('result').innerHTML = 'not supported';
} else if (evt.data === 'MM:3PCsupported') {
document.getElementById('result').innerHTML = 'supported';
}
};
window.addEventListener("message", receiveMessage, false);
However, this solution doesn't seem to work any more.