Skip to content

Instantly share code, notes, and snippets.

@luigimannoni
Last active October 29, 2015 13:22
Show Gist options
  • Select an option

  • Save luigimannoni/0e3396ba2d4a85e67e7b to your computer and use it in GitHub Desktop.

Select an option

Save luigimannoni/0e3396ba2d4a85e67e7b to your computer and use it in GitHub Desktop.
Eventsforce Safari cookie redirect
// Script to sit inside the form page
var cookies = document.cookie;
var referrer = document.referrer;
var isSafari = /^((?!chrome).)*safari/i.test(navigator.userAgent);
if(isSafari && !navigator.userAgent.match('CriOS')) {
if ((cookies === '' ||
!cookies ||
typeof(cookies) == 'undefined' ||
typeof(cookies) == 'null' ||
typeof(cookies) == 'false')) {
document.cookie = 'pageVisited=yes';
window.location.href = document.referrer;
}
}
// Script sitting inside STA
// Safari Cookie trick!
// Check if it's safari and filter out chrome on iOS since it reports itself as Safari.
var isSafari = /^((?!chrome).)*safari/i.test(navigator.userAgent);
if(isSafari && !navigator.userAgent.match('CriOS')) {
var cookie = Cookies.get('staEventsForceIframeVisited');
if (cookie != 'yes') {
// If it's not visited trigger the refresh
var url = $('#sta-eventsforce-iframe').attr('src');
window.location.href = url;
Cookies.set('staEventsForceIframeVisited', 'yes');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment