Last active
October 29, 2015 13:22
-
-
Save luigimannoni/0e3396ba2d4a85e67e7b to your computer and use it in GitHub Desktop.
Eventsforce Safari cookie redirect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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