Link to home
Create AccountLog in
Avatar of lapucca
lapucca

asked on

Anyway to detect if browser is FireFox then prompt user to download Microsoft Media Plugin?

Hi, using c#, asp.net 3.5 and jQuery/javascript
What's the best way to detect FF browser then prompt and direct user to download MS Media Plugin from FireFox (if they don't have it installed yte)?   Our video clip isn't playing in scale down size when in FF browser but works fine in IE.  Thank you.
Avatar of DonConsolio
DonConsolio
Flag of Austria image

Check this page for example : http://www.w3schools.com/js/js_browser.asp

you may use : navigator.userAgent.toLowerCase().indexOf("firefox")>=0

Test page :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
	window.onload = function() {
		if( navigator.userAgent.toLowerCase().indexOf("firefox")>=0 )  {
			if( confirm("do you want to load MS Media Plugin for Firefox") ) {
				location.href = "http://www.microsoft.com" 
			}
		}
	}
</script>
</head>
<body>
</body>
</html>

Open in new window

Avatar of lapucca
lapucca

ASKER

Well, I don't want to ask the user every time they open up the FF browser to download.  Is there a way to detect if they have the FF Window Media Plugin installed?  If not then prompt and direct them to download and install the pluging.  How can I do this either in javascrip/jquery or C#
Thank you.
Do you have the plugin installed on your side ? We need to found a valid description or type

Check this :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script language="javascript">
	$(document).ready(function() {
		for(i in navigator.plugins) {
			try {
				$("body").append( "<div>Type :&nbsp;" + navigator.plugins[i][0].type + "</div>" );
				$("body").append( "<div>Desc :&nbsp;" + navigator.plugins[i][0].description + "</div>" );
				$("body").append( "<div>Desc :&nbsp;" + navigator.plugins[i][0].name + "</div><br />" );
			} 
			catch(e) {}
		}		
	});
</script>
</head>
<body>
</body>
</html>

Open in new window


if you need help to handle the way to get it, post what you get, I will modify the following script :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script language="javascript">
	$(document).ready(function() {
		if( navigator.userAgent.toLowerCase().indexOf("firefox")>=0 && WMPNotInstalled() )  {
			if( confirm("WMP is not nstalled!\nDo you want to load MS Media Plugin for Firefox") ) {
				location.href = "http://www.microsoft.com" 
			}
		}
	});
	
	function WMPNotInstalled() {
		for(i in navigator.plugins) {
			try {
				var desc = navigator.plugins[i][0].description.toLowerCase();
				var name = navigator.plugins[i][0].name.toLowerCase();
				if( name.indexOf("") == "Media Player" || desc.indexOf("") == "Media Player" ) { // We need to replace "Media Player" here
					return false; // found!
				}
			}
			catch(e) {}
		}
		return true; // not found!
	}

</script>
</head>
<body>
</body>
</html>

Open in new window

Look for Detecting Acrobat Reader & others in this page : http://oreilly.com/pub/a/javascript/2001/07/20/plugin_detection.html
The function detectNS do the job

Seems the good type is : application/x-mplayer2

Avatar of lapucca

ASKER

Attached is the output but I cannot tell which one is it though  Thank you.
FF-plugin.html
You did not confirm you have it or not... Seems you don't have the plugin installed. Please confirm.
Avatar of lapucca

ASKER

Yes, i do have it installed just a couple of days ago and I teseted it it works
Avatar of lapucca

ASKER

Here is a screen shot of what's installed on my FF.  It's the middle highlighted one.  Maybe I didn't say the name correctly.
FFPlugins.JPG
Try this :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">

	window.onload = function() {
		var nse = ""; for(var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes.type.toLowerCase();
		if( navigator.userAgent.toLowerCase().indexOf("firefox")>=0 && nse.indexOf("application/x-mplayer2")<0 )  {
			if( confirm("do you want to load MS Media Plugin for Firefox") ) {
				location.href = "http://www.microsoft.com" 
			}
		}
	}

</script>
</head>
<body>
</body>
</html>

Open in new window

Avatar of lapucca

ASKER

I uninstalled the plugin , restart my FF and check to make sure that plugin is un-installed.  I then ran my program, aspx, with your script in it but nothing happened though.  Thank you.
Avatar of lapucca

ASKER

I just saved your file, then open it with FF and still nothing happened either.  Thank you.
I get the message on my side (never installed the plugin)
Clipboard04.jpg
Avatar of lapucca

ASKER

I'm running FF 3.6.13.  Maybe there is some setting I need to configure for it?
Avatar of lapucca

ASKER

Well, FF Javascript is enabled in the option.  I wonder why it's not working.
Please try it on another computer.

With this part : nse.indexOf("application/x-mplayer2")<0
we cheack if the plugin is installed. It seems the plugin still present on your FF.

Additionnaly we add : navigator.mimeTypes["application/x-mplayer2"].enabledPlugin != null
To check if the plugin is enable or not :



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">

	window.onload = function() {
		var nse = ""; for(var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes.type.toLowerCase();
                var classID = "application/x-mplayer2";
		if( navigator.userAgent.toLowerCase().indexOf("firefox")>=0 && ( nse.indexOf(classID)<0 || navigator.mimeTypes[classID].enabledPlugin==null ) )  {
			if( confirm("do you want to load MS Media Plugin for Firefox") ) {
				location.href = "http://www.microsoft.com" 
			}
		}
	}

</script>
</head>
<body>
</body>
</html>

Open in new window

Avatar of lapucca

ASKER

It turns out the plugin is still on my pC.  I didn't quite find the option to remove it.  So, I try it on our new web server, win2003.  I downloaded the FF and installed it.  I make sure it has no plugin installed on it.  ran the program and still nothinkg happens.  
Is there a way to uninstall the plugin from my dev pc to test this?  There is only option for dis-enable it.
>So, I try it on our new web server, win2003.  I downloaded the FF and installed it.  I make sure it has no plugin installed on it.  ran the program and still nothinkg happens.  

So the code don't work ? You don't have the alert box like me on the win 2003 srv ?
Avatar of lapucca

ASKER

Nope, no alert box at all.  I will ask someone else to try and see if it will work for them.  I know for sure they don't have the plugin either.
OK, I will try it on another box too...
Avatar of lapucca

ASKER

Ok, my program is doing something very funky on that win2003 server.  The same code when I deploy to there it takes me to a different but similar page.  But in that content page I also put a copy of your javascript but doesn't show up in the pagesource view.  However, there is a label to download plugin but I don't thing tha's from your javascript though.  The screen shot is attached.
FF-Plugin.doc
I was thinking you tried my full test page alone before enmbed it in your page >:o(
Avatar of lapucca

ASKER

Oh, OK, I will do that now.
Avatar of lapucca

ASKER

Humm.. Still nothing happened.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of lapucca

ASKER

Leak, Thank you for all your help.