How to restrict to web application to specific Browser [duplicate] - javascript

This question already has answers here:
How to detect Safari, Chrome, IE, Firefox and Opera browsers?
(30 answers)
Closed 6 years ago.
I am using asp.net in backend and Javascript (ExtJs) in frontend. I want my web app to open in some particular browser. ex: IE11. I thought to try noscript tag But not getting any idea how to get this.
Suppose I am able detect my browser then How I will restrict to IE 11 only.
Can anybody suggest what I need to do.

Maybe you can try something like the following:
var userAgent = window.naviagtor.userAgent;
if (userAgent === 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';) {
//is IE11
}

I think IE11 still uses ActiveX, you can try to detect if the browser support ActiveX combine with user-agent.But this is not necessarily to say if the browser doesn't support ActiveX is not IE11, like security is on ...

Related

Why is the User-Agent of Opera mini printed strangely on iPad?

I print User-Agent string of Opera mini on iPad using JavaScript like below.
alert(navigator.userAgent);
Result is
Mozilla/5.0 (iPad; CPU OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15G77
I don't know how can I detect this browser that is Opera Mini.
Why is the User-Agent of Opera mini printed strangely on iPad?
Opera 16 runs with Webkit engine, hence the different user agent.
With Webkit it now support a lot of features the older version (using the Presto engine) didn't.
The reason they changed it, is most like to get by many web servers that will block the older Opera, where they often is spoofing the user agent, and when finding opera mini, block it as being outdated (and note, Microsoft did a similar trick with Windows phone)
...how can I detect this browser that is Opera Mini
Short answer, you can't
Longer answer, there are CSS features like -o-prefocus, media query hacks etc., many of them you can find here: http://browserhacks.com/
The downside with these, when that browser specific property disappears, so will your detection.
Instead, embrace the more future proof way and detect a feature, with e.g. #supports()
At this question there is some more interested reading with how-to using both CSS and script
Instead of using prefixes I want to ask site visitors to upgrade their browser

How can I detect the users browser client side? [duplicate]

This question already has answers here:
How to detect Safari, Chrome, IE, Firefox and Opera browsers?
(30 answers)
Closed 6 years ago.
I know this is bad practice and feature recognition should be the way to go in terms of building the website. However that is not my use case.
I have different distributions of my browser extension and I would like to change the download button based on their current browser.
I've tried using navigator.userAgent, that has proven to be quite useless as most browsers have set all popular user agents. For example chrome has this.
navigator.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36"
I've seen many websites have this feature on their download buttons. How is this done properly?
EDIT: I've now learned the history of why "Mozzila/X.X" is at the start of the userAgent string. Apologies for the misunderstanding.
You can detect browsers in multiple ways.
For Chrome, apart from making a regex on the navigator.userAgent:
var isChrome = /Chrome/.test(navigator.userAgent);
You can also make a check on:
var isChrome = !!window.chrome && !!window.chrome.webstore;
I suggest you to see this answer for further details.
You should also consider using Modernizr.js for browser detection.

Internet Explorer ver 11 enterprise mode detection

Recently my team has landed in a weird situation. End of last year we migrated from IE 8 to IE 11. Our application is now designed to work in IE 11 Enterprise mode.
We need to display a javascript alert message to upgrade the Browser if the user is using IE 8. Alert message is successfully displayed to the users who use IE 8. But problem occurs when the alert message is also displayed to the users who are using IE11 in enterprise mode. I know that IE11 Enterprise mode basically emulates IE 8 behavior and that is the reason why our browser detection functionality is failing.
So I wanted to check if someone has implemented this kind of feature where they can successfully detect the IE version even if they are using IE 11 enterprise mode.
All responses are valuable. Appreciate your response !!!
As per MSDN:
As of Internet Explorer 11, the user-agent string has changed
significantly...Sites that rely on the user-agent string should be
updated to modern techniques, such as feature detection, adaptive
layout, and other modern practices.
https://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
Although IE11 in EM throws
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; Tablet PC 2.0)
It is not advisable to just look for "MSIE" in the userAgent but rather try:
var isIE11 = !!navigator.userAgent.match(/Trident.*rv[ :]*11\./)
I'm just looking into this myself. I did stumble across this recently - but couldn't get it to work reliably - however the concept of looking for a feature of IE that shouldn't normally be available is sound.
My plan now is to use IETruth to get the version number (it's very good at doing version detection for IE11) and then do something like:
var IE = IeVersion();
if(IE.TrueVersion < 9 && ('spellcheck' in document.createElement('textarea')) {
// must be running in Enterprise mode because spellcheck wasn't introduced until IE10
}
I'll let you know how I get on!
You can use document mode to check for Enterprise mode. Because in EM the document mode is set to IE 5 to IE 8. This check along with your browser check functionality should work.
How to get browser "Document Mode"

How can I look up my created webpages on internet explorer 8 or older? [duplicate]

This question already has answers here:
Software/tool to test/check web-application in multiple browsers?
(8 answers)
Closed 8 years ago.
I am using windows7 and it supports only internet explorer 9. I work on web pages designing on my chrome browser. But you know, some of the CSS features dnt support in Enternet Explorer 8 or erlier. But when I trying to download Internet explorer 8 to my Win7 OS it never downgrade IE from 9th to 8th. Then how can I look up my created web pages on IE8 ? Plz help
Do you have Developer tools? Then change the "Browser mode" and "Document Mode" to check the web page behaviour in lower versions .
You can use:
http://netrenderer.com/ to check all IE versions screenshoots
http://cloudinternetexplorer.com/ to check IE live (IE9 only)
https://browserling.com/ to check IE, Chrome, Firefox, Opera, Safari versions
http://www.browserstack.com/ is commercial, but have a free trial
http://crossbrowsertesting.com/ is commercial, but have a free trial too
etc...
EDIT: I recommend, if you are using CSS3, to use http://css3pie.com/ is a super htc app, that make major CSS3 function to work in IE.
Hope this will help you!
IETester allows you to run multiple versions of IE shells:
http://my-debugbar.com/wiki/IETester/HomePage

jQuery - detecting the operating system and operating system version

I have been writing a userscript for the past few months, for my company, and have just designed the main site for it with installation instructions (our employees are based all around the world and very few have heard of userscripts, let alone used them, so this frontend is meant to cut down the time I spend supporting the script).
What I would like to do is, on the installation page, detect which browser and OS / OS version they're using so that I can highlight the most relevant instructions slightly darker than the rest, or simply not display irrelevant sections.
For example for IE6 you must use Trixie (I believe) to install userscripts, and this is supported on Win XP only. IE7 is supported on Win XP, IE8 is supported on Win XP & Win 7 and IE9 is supported on Win 7 only. For IE7, 8 & 9 I am advising to use IEPro. The difference between Trixie & IEPro is that Trixie requires a file extension of .user.js which must be saved in C:/Program Files/bhelpuri. IEPro, on the other hand, requires the extension to be .ieuser and saves to a different location. For IE specifically, I would like to detect the version and display only the correct link (either .user.js or .ieuser, depending on what plugin they should be using for their current browser) so that they're taken to the correct version of the file for that browser with the correct save path for that OS / OS version. Is this making any sense so far?
Basically my question is, does anyone know of a way to detect the operating system version? I am currently using http://www.stoimen.com/blog/2009/07/04/jquery-os-detection/ but that doesn't give the OS version, only the OS. I have tried looping through all of the variables stored in the navigator object with no success. Any help would be greatly appreciated.
Edit: Thanks to Nates answer, I have put the exact code at http://jsfiddle.net/Mu8r5/1/. I hope this helps someone in the future.
Your best bet is to use the navigator.userAgent property. It will give the windows version number. You can see a table of how the Windows version number map to the OS here:
OSVERSIONINFO
Here is some example detection code:
var os = (function() {
var ua = navigator.userAgent.toLowerCase();
return {
isWin2K: /windows nt 5.0/.test(ua),
isXP: /windows nt 5.1/.test(ua),
isVista: /windows nt 6.0/.test(ua),
isWin7: /windows nt 6.1/.test(ua),
isWin8: /windows nt 6.2/.test(ua),
isWin81: /windows nt 6.3/.test(ua)
};
}());
if(os.isWin7) {
...
}
http://jsfiddle.net/45jEc/
You can use this great javascript library: http://www.visitorjs.com/details It is open-sourced recently
Edit: Actually, it is now renamed to session.js http://github.com/codejoust/session.js and to my knowledge, that is the best you can get.
The Stack Overflow question
Detect exact OS version from browser goes into some interesting detail about getting the OS version from the User-Agent header which I believe contains the same information that can be accessed from JavaScript.

Categories

Resources