Skip to content

Instantly share code, notes, and snippets.

@codepo8
Created June 19, 2012 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codepo8/2955313 to your computer and use it in GitHub Desktop.
Save codepo8/2955313 to your computer and use it in GitHub Desktop.
Detecting Firefox and thanking users
(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