inherit
43534
0
Aug 19, 2005 13:41:28 GMT -8
stevezz87
25
May 2005
stevezz87
|
Post by stevezz87 on Jun 19, 2005 14:20:37 GMT -8
I was wondering if anyone could give me a code that would detect if the visitor is using firefox and that if firefox is detected I could run a specific code. It would be really helpful. I'm doing this because in IE I have a code working perfect that does not work on Firefox but with an added code will work on Firefox however if I keep the added code in and visit from IE I have an error.
So basically I just need a code that detects the browser and has an if statement saying if the browser is firefox run this code.
Any help is appreciated Thanks in advance.
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Jun 19, 2005 15:25:37 GMT -8
<script type="text/javascript"> <!--
var isFF = (navigator.userAgent.split("/")[0].match(/mozilla/i))? true : false;
if(isFF){ alert("Using Mozilla Firefox"); } else { alert("For other browsers"); }
//--> </script>
|
|
inherit
43534
0
Aug 19, 2005 13:41:28 GMT -8
stevezz87
25
May 2005
stevezz87
|
Post by stevezz87 on Jun 19, 2005 16:11:34 GMT -8
That doesn't seem to work. It says using mozilla firefox when i open it with IE.
|
|
inherit
Proboards Legend
212
0
May 11, 2006 12:32:55 GMT -8
california
21,035
December 1999
california
|
Post by california on Jun 19, 2005 23:01:56 GMT -8
Try this:
<script type="text/javascript"> <!--
var IE = (navigator.appName.match(/internet explorer/i)) ? true : false;
if(IE){ alert("Using Internet Explorer"); } else { alert("For other browsers"); }
//--> </script>
I'd say it would be better to do it this way, because if a code doesn't work in FireFox it probably doesn't work in any other browser besides IE anyway.
|
|
#00AF33
Official Code Helper
19529
0
1
Nov 19, 2012 14:18:28 GMT -8
Todge
**
17,324
January 2004
todge
|
Post by Todge on Jun 19, 2005 23:56:08 GMT -8
I always use document.all..
<script type="text/javascript"> <!--
if(document.all){ Code for IE } else{ Code for Firefox }
//--> </script>
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Jun 20, 2005 13:47:33 GMT -8
Try this: <script type="text/javascript"> <!--
var IE = (navigator.appName.match(/internet explorer/i)? true : false;
if(IE){ alert("Using Internet Explorer"); } else { alert("For other browsers"); }
//--> </script>I'd say it would be better to do it this way, because if a code doesn't work in FireFox it probably doesn't work in any other browser besides IE anyway. Errr...nooo. Browsers (FF, Opera etc) can be set to act like IE, only way to check would be to do object detection or other means, like user agent, or vendor
|
|
inherit
43534
0
Aug 19, 2005 13:41:28 GMT -8
stevezz87
25
May 2005
stevezz87
|
Post by stevezz87 on Jun 20, 2005 14:44:35 GMT -8
Okay thanks alot I got it to work but the code was missing a ) so you need to add it after /i)
|
|
inherit
Proboards Legend
212
0
May 11, 2006 12:32:55 GMT -8
california
21,035
December 1999
california
|
Post by california on Jun 20, 2005 22:24:01 GMT -8
Errr...nooo. Browsers (FF, Opera etc) can be set to act like IE, only way to check would be to do object detection or other means, like user agent, or vendor I figured that affected the userAgent property as well. And I know Opera can do that, but I've never seen any FF setting for it.
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Jun 21, 2005 14:51:05 GMT -8
Errr...nooo. Browsers (FF, Opera etc) can be set to act like IE, only way to check would be to do object detection or other means, like user agent, or vendor I figured that affected the userAgent property as well. And I know Opera can do that, but I've never seen any FF setting for it. Nope, I believe user agent is harder to spoof (don't quote me on that), but anyway, appName is no good really, like I said, browsers like Opera, and Mozilla (One of them do. FF was wrong, but I believe there are extensions for it), and there are probably more of them about which have a setting to act like IE.
|
|