Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-02-10
26
Medium Priority
?
523 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 82

Expert Comment

by:leakim971
ID: 34867666
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
ID: 34867930
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 82

Expert Comment

by:leakim971
ID: 34868069
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
ID: 34868104
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
ID: 34868129
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
ID: 34868137
You did not confirm you have it or not... Seems you don't have the plugin installed. Please confirm.
0
 

Author Comment

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

Author Comment

by:lapucca
ID: 34868147
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
ID: 34868159
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
ID: 34868220
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
ID: 34868229
I just saved your file, then open it with FF and still nothing happened either.  Thank you.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34868242
I get the message on my side (never installed the plugin)
Clipboard04.jpg
0
 

Author Comment

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

Author Comment

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

Expert Comment

by:leakim971
ID: 34871142
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
ID: 34873846
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
ID: 34873879
>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
ID: 34873950
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
ID: 34873967
OK, I will try it on another box too...
0
 

Author Comment

by:lapucca
ID: 34874293
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
ID: 34874313
I was thinking you tried my full test page alone before enmbed it in your page >:o(
0
 

Author Comment

by:lapucca
ID: 34875219
Oh, OK, I will do that now.
0
 

Author Comment

by:lapucca
ID: 34875238
Humm.. Still nothing happened.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 34876346
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
ID: 34913675
Leak, Thank you for all your help.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
Suggested Courses

963 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