Solved

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

Posted on 2011-02-10
26
515 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:lapucca
  • 14
  • 11
26 Comments
 
LVL 14

Expert Comment

by:DonConsolio
Comment Utility
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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

0
 

Author Comment

by:lapucca
Comment Utility
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.
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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

0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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

0
 

Author Comment

by:lapucca
Comment Utility
Attached is the output but I cannot tell which one is it though  Thank you.
FF-plugin.html
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
You did not confirm you have it or not... Seems you don't have the plugin installed. Please confirm.
0
 

Author Comment

by:lapucca
Comment Utility
Yes, i do have it installed just a couple of days ago and I teseted it it works
0
 

Author Comment

by:lapucca
Comment Utility
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
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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

0
 

Author Comment

by:lapucca
Comment Utility
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.
0
 

Author Comment

by:lapucca
Comment Utility
I just saved your file, then open it with FF and still nothing happened either.  Thank you.
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
I get the message on my side (never installed the plugin)
Clipboard04.jpg
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:lapucca
Comment Utility
I'm running FF 3.6.13.  Maybe there is some setting I need to configure for it?
0
 

Author Comment

by:lapucca
Comment Utility
Well, FF Javascript is enabled in the option.  I wonder why it's not working.
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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

0
 

Author Comment

by:lapucca
Comment Utility
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.
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
>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 ?
0
 

Author Comment

by:lapucca
Comment Utility
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.
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
OK, I will try it on another box too...
0
 

Author Comment

by:lapucca
Comment Utility
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
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
I was thinking you tried my full test page alone before enmbed it in your page >:o(
0
 

Author Comment

by:lapucca
Comment Utility
Oh, OK, I will do that now.
0
 

Author Comment

by:lapucca
Comment Utility
Humm.. Still nothing happened.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
I was testing my first test page (ID:34868159)... sorry...

Check this one :


<!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 = "";
		try {
			for(var i=0;i<navigator.mimeTypes.length;i++) {
				nse += navigator.mimeTypes[i].type.toLowerCase();
			}
		}
		catch(e){}
		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

0
 

Author Closing Comment

by:lapucca
Comment Utility
Leak, Thank you for all your help.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now