Created
June 19, 2012 17:04
-
-
Save codepo8/2955313 to your computer and use it in GitHub Desktop.
Detecting Firefox and thanking users
This file contains 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
(function(){ | |
var messages = { | |
'Firefox': ''+ | |
'<h2>Thanks for using Firefox!</h2>'+ | |
'<img src="http://misfitgeek.com/images/firefox3.jpeg" alt="Firefox">', | |
'FirefoxAndroid': ''+ | |
'<h2>Thanks for using Firefox for Android!</h2>'+ | |
'<img src="http://misfitgeek.com/images/fennec-icon.jpeg" '+ | |
' alt="Firefox Mobile">', | |
'Android': ''+ | |
'<h2>Get Firefox Mobile!</h2>'+ | |
'<a href="http://www.mozilla.org/en-US/mobile/">'+ | |
'<img src="http://misfitgeek.com/images/fennec-icon.jpeg" '+ | |
' alt="Firefox Mobile"></a>'+ | |
'<strong>Click the Tail & Get Firefox Mobile for Android!</strong>', | |
'NonAndroid': ''+ | |
'<h2>Please consider using Firefox!</h2>' + | |
'<a title="Get FireFox !" href="http://getfirefox.org/">'+ | |
'<img src="http://misfitgeek.com/static/getfirefox.png" '+ | |
' alt="Get Firefox">'+ | |
'</a>' | |
}; | |
var out = ''; | |
var isAndroid = navigator.userAgent.toLowerCase().indexOf("android") > 0; | |
var isFirefox = typeof window.mozPaintCount === 'number'; | |
if (isFirefox) { out = messages['Firefox']; } | |
if (isFirefox && isAndroid) { out = messages['FirefoxAndroid']; } | |
if (!isFirefox && isAndroid) { out = messages['Android']; } | |
if (!isFirefox && !isAndroid) { out = messages['NonAndroid']; } | |
var msg = document.createElement('div'); | |
msg.innerHTML = out; | |
var me = document.getElementById('firefoxtest'); | |
me.parentNode.replaceChild(msg, me); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment