-2

Please not not turn this into a discussion about which browser is better and the ethics of forcing a browser. It's an intranet, and it's what I am required to do so everyone calm down =o)

I need to prevent employees from trying to bypass the check to not use their preferred browser instead of the company mandated one + version. The decision was made based on security, compatibility, costs, and the use of company made Firefox extensions.

I came across this Force users to use Chrome/FireFox instead of IE which I can do easily in PHP to force use of Firefox, however it relies on the useragent which can easily be changed in numerous browsers and with the use of plugins.

Is there a JavaScript solution that I can use that DOES NOT check the useragent or any value that can be 'easily' modified by a user/plugin? It would need to detect if the browser is Firefox and what version it is. Site uses jQuery so if it can be done using that, however not required then by all means yes. I just am not aware of what ways to detect a browser and it's version that there are without checking useragent.

I remember way back in the day for detecting Netscape or some browser checking for document.all was used instead of useragent, so I'm guessing something similar, which only Firefox will have.

Thank you very much in advance!

Community
  • 1
  • 1
kittycat
  • 14,983
  • 9
  • 55
  • 80
  • Forcing FF makes even less sense (particularly on intranets) than forcing IE. At least IE comes with Windows and has decent ActiveX support. – cHao Nov 15 '12 at 05:16
  • That likely one of the reasons it is being forced instead. Company does not use Windows. All Linux based =o) – kittycat Nov 15 '12 at 05:19
  • Ah, so they're cultists. That explains a bit. It's still boneheaded, though. Makes more sense to simply build the site to work with FF and say you don't support anything else...or, even better, to give a damn about standards and end up working in a real browser like Chrome. :) – cHao Nov 15 '12 at 05:23
  • Chromium was 2nd on the list, but we are not sure if we could easily port over the extensions to work in it. – kittycat Nov 15 '12 at 05:44

2 Answers2

3

Try this: http://jsfiddle.net/DerekL/62exH/

Because Firefox handles onpopstate differently than other browsers, you can then use this to detect if it is Firefox or not. This can not be changed by user or script. But the disadvantage is you can only get the version number by doing navigator.appVersion.

Derek 朕會功夫
  • 92,235
  • 44
  • 185
  • 247
  • 1
    very sneaky, I like this and should work for 99.9% of users. Even so, any data being passed from js to a server can be mimicked. You could fake this very easily through the console before submitting. – James L. Nov 15 '12 at 05:25
  • 1
    @James: If someone's going through that much effort, they're pretty much *going* to get in, regardless of what browser they use. Any approach should probably limit itself (for sanity's sake, really) to the people that aren't actively *trying* to bypass the restriction, cause those people aren't gonna be stopped anyway. – cHao Nov 15 '12 at 05:32
  • It just depends on your level of technical acumen. It wouldn't be any effort for me or you to break but would be for 99.9% of users. – James L. Nov 15 '12 at 05:34
  • 1
    @James: If someone's forging data, though, it's pretty safe to say they're in the 0.1% too. :) Protecting against them is going too far...and is doomed to failure anyway, really. – cHao Nov 15 '12 at 05:36
  • I never said you should protect against the .1% so I'm not sure I understand your comment. I was simply pointing out the fact that although this is "very sneaky and I like this", this is not a 100% foolproof method (and none exists to the best of my knowledge). I'm the lone upvote as this satisfied the OP's request of not being 'easily' modified so I'm not clear what issue you are raising here. – James L. Nov 15 '12 at 05:49
  • I found this https://developer.mozilla.org/en-US/docs/Mozilla_event_reference there are a few non-deprecated Moz specific events listed, any recommendation on which one would be good to check for on pageload? I'm guessing I should be able to even check for multiple items and as long as one satisfies it should be flagged as Firefox, hopefully that will last longer before code has to be updated due to deprecation. =o\ – kittycat Nov 15 '12 at 06:01
  • @cryptic - You can also check other Firefox-specific things (both JavaScript and CSS) to make sure it is Firefox, for example, `-moz-calc`. – Derek 朕會功夫 Nov 15 '12 at 08:14
1

You can only try but cannot succeed in forcing a browser. That being said you can strip down the CSS in other browsers which may completely make your site close to unusable in other browsers.

To make your CSS only work with Firefox you can try approaches given @ Targeting only Firefox with CSS

Community
  • 1
  • 1
Ramesh
  • 13,043
  • 3
  • 52
  • 88