When I use swfobject.getFlashPlayerVersion() on IE11 with flash version older than current 15.0.0, I always get "0.0.0" as the result. (with version 15 it works correctly)
I have tested it with both flash player plugin on FF and active x on IE. With Firefox, everything works correctly. Swfobject FAQ states in question 3 that some versions may give incorrect results, but it does not mention returning "0.0.0" and also I have tested flash player versions 9, 10, 10.2, 10.3, 11.3 and 13 and the result in IE was always the same.
I really need to get the correct version of flash player installed in IE. Is there any solution to this problem? Are there any other options how to reliably get the correct flash player version?
EDIT: There was a question what swfobject does to look up the version. Well this is the part of the code that does it:
if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
d = nav.plugins[SHOCKWAVE_FLASH].description;
if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
plugin = true;
ie = false; // cascaded feature detection for Internet Explorer
d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
}
}
else if (typeof win.ActiveXObject != UNDEF) {
try {
var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
if (a) { // a will return null when ActiveX is disabled
d = a.GetVariable("$version");
if (d) {
ie = true; // cascaded feature detection for Internet Explorer
d = d.split(" ")[1].split(",");
playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
}
}
}
catch(e) {}
}
I found out that in IE10 it goes to the else if part (flash version does not matter) while in IE11 with flash 15 it goes to the first if . However, with IE11 and older flash it skips both conditions:
window.ActiveXObject is undefined in IE11 (as it should be, or at least that's what I have found)
but it also skips the first if and when I look at navigator.plugins there aren't any despite having the flash 11.0 installed
Where is the problem? Why the older flash is not listed in my IE11 plugins?
Related
I am working on a Browser Check for the school that I work at. I have a .js file where I am pulling information to a html page to display the name of the browser and the its version. Unfortunately with Windows Edge the token that is displayed is 13.1 or 12.1 depending on which version of Edge you are using.
These are the edgeHTML versions not the actual displayed version for Edge.
I have been trying to find a way to display the actual Edge versions 20 and 25 but not getting anywhere.
I have tried using IF ELSE statements but when I do it just renders the number listed in the second line of the IF part of the statement no matter if I am using Edge 20 or 25. Please help.
case browserUserAgent.indexOf('edge') >= -1: // browser is Edge, check the gorilla first
browserAgent = 'Edge';
browserVersion = browserUserAgent.split('edge/');
browserVersion = browserVersion[1].split(0, 3);
browserVersion = browserVersion[0];
if (browserVersion = '12.1') {
browserVersion = '20';
} else if (browserVersion = '13.1') {
browserVersion = '25';
}
break;
Since (public) EdgeHTML versions maps 1-to-1 against Edge browser versions, you can do this:
// map (major versions of) EdgeHTML to Edge
var EDGEHTML_TO_EDGE = {
12: 20,
13: 25
};
// regexp which matches edge user strings
var EDGE_REGEXP = /Edge\/(\d+)/;
// check if the regexp matches the user agent
var edgeMatch = browserUserAgent.match(EDGE_REGEXP);
if (edgeRegexp) {
var edgeHtmlVersion = edgeMatch[1]; // the major EdgeHTML version number
var edgeVersion = EDGEHTML_TO_EDGE[edgeHtmlVersion];
document.write('You are running Edge ' + edgeVersion);
}
EDIT: A much simpler and straight forward method:
if (/Edge\/12\.1/.test(browserUserAgent)) {
document.write('You are running Edge 20');
} else if (/Edge\/13\.1/.test(browserUserAgent)) {
document.write('You are running Edge 25');
}
I have not been able to test it myself as I don't have Edge, but it should give you the idea. I'm basically getting the major version number reported by the User Agent and then mapping that to the known Edge browser versions.
If you intend to test for other browsers too, you can try the browser npm package.
I am trying to detect if the user is navigating my website from safari browser on the iphone using jquery / javascript.
I am able to detect the IOS Environment using the user agent string
/iphone/i.test(navigator.userAgent.toLowerCase())
But this detects the Apple Webkit Environment i.e. it is same for all the browsers on the device. Can anyone suggest any different approach.
UPDATED:
Try this, for detecting Safari browser in an iPhone:
var isSafari = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);
It identifies Safari 3.0+ and distinguishes it from Chrome.
JsFiddle
Since the other answer doesn't include detection of an iPhone, including that part.
var isIphone = /(iPhone)/i.test(navigator.userAgent);
var isSafari = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);
if(isIphone && isSafari){
//do something
}
If you want to detect a particular iOS version and above, say iOS 7.0 and above then you can use the below code. It detects iOS version 7-19(for upcoming versions).
var isIphone= /(iPhone)*(OS ([7-9]|1[0-9])_)/i.test(navigator.userAgent);
var isFirefox = navigator.userAgent.indexOf("FxiOS") != -1;
var isChrome = navigator.userAgent.indexOf("CriOS") != -1;
var isEdge = navigator.userAgent.indexOf("EdgiOS") != -1;
var isOpera = navigator.userAgent.indexOf("OPT") != -1;
if (!isFirefox && !isChrome && !isEdge && !isOpera){
console.log("Only display in Safari")
} else {
console.log("Only display in Firefox/Chrome/Edge/Opera")
}
Hi, this way worked for me to detect only safari in ios mobile. The value FxiOs, CriOs, etc, I get from the userAgent value.
This question already has answers here:
Detect iOS version less than 5 with JavaScript
(9 answers)
Closed 9 years ago.
I come across bugs with fixed positionning on iOs (fixed menu on bottom, coming on the middle of screen when the keyboard comes up).
The thing is, this bug only happens on iOs 6.1.4. So the fix i've just done works for iOs 6.1.4 (this one : http://dansajin.com/2012/12/07/fix-position-fixed/), but makes the menu coming to the middle on the screen on iOs 6.1.3...
Is there a way to detect the current version of iOs in JS ?
Have you tried using console.log(navigator); to grab information regarding the browsing machine?
navigator.userAgent or navigator.platform will provide you with the basis for what you need, that said I'm not so sure you'll be able to track it down to such a specific degree.
You can also try this snippet of code:
function iOSversion() {
if (/iP(hone|od|ad)/.test(navigator.platform)) {
// supports iOS 2.0 and later: <http://bit.ly/TJjs1V>
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
}
}
ver = iOSversion();
if (/(iPad|iPhone|iPod)/g.test( navigator.userAgent ) && ver[0] == 6 && ver[1] ==1 && ver[2]==3) {
alert('This is running iOS 6.1.3 or later.');
}
Adapted from here
My recommendation would be always to attempt to fix the underlying issue rather than implement a workaround, however I appreciate this can sometimes be impractical.
According to this post the iOS version (above 2.0) can be found with:
function iOSversion() {
if (/iP(hone|od|ad)/.test(navigator.platform)) {
// supports iOS 2.0 and later: <http://bit.ly/TJjs1V>
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
}
}
ver = iOSversion();
if (ver[0] === 6.14) {
alert('This is running iOS 6.14.');
}
Developing a frontend realtime javascript application, we have decided to drop support for older browsers since it takes too much effort to support them.
What header or javascript should we add in the HTML, so that when they hit the URL, I can redirect them a page to obtain newer browsers before proceeding to our application?
you can use following properties of navigator object
navigator.appCodeName
navigator.appName
navigator.appVersion
navigator.cookieEnabled
navigator.platform
navigator.userAgent
you can also use jquery browser object
http://api.jquery.com/jQuery.browser/
The better option is to use feature detection. For example, to test if a browser has geolocation support, you can use the following:
if (navigator.geolocation)
{
// interact with geolocation features
}
If you insist on using browser detection instead, however, you can use the following to detect if the browser is using IE 8 or below:
function getInternetExplorerVersion()
// Returns the version of Windows Internet Explorer or a -1
// (indicating the use of another browser).
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}
var ver = getInternetExplorerVersion(); // example: 8.0
var belowIE8 = ver <= 8.0;
Found here: http://www.mkyong.com/javascript/how-to-detect-ie-version-using-javascript/
If you want to determine this based on a particular JavaScript version, see below code (untested):
<script language="javascript1.5">
var supported = true;
</script>
<script>
if ('undefined' === typeof supported) {
alert('not at least 1.5 supported');
}
It's still better to do feature detection though, as that ties in better with what you're going to use it for.
Amazon.com recently updated their javascript, and it's causing problems with some Opera browsers.
Their browser detection code looks like so, but it's faulty:
function sitbReaderIsCompatibleBrowser() {
if (typeof(jQuery) == 'undefined') {
return false;
} else {
var version = jQuery.browser.version || "0";
var splitVersion = version.split('.');
return (
(jQuery.browser.msie && splitVersion[0] >= 6) // IE 6 and higher
|| (jQuery.browser.mozilla && (
(splitVersion[0] == 1 && splitVersion[1] >= 8) // Firefox 2 and higher
|| (splitVersion[0] >= 2)
))
|| (jQuery.browser.safari && splitVersion[0] >= 500) // Safari 5 and higher
|| (jQuery.browser.opera && splitVersion[0] >= 9) // Opera 5 and higher
);
}
}
Nothing obviously wrong jumps out at me with this code, but I've never used jQuery before so I don't know.
Even though this code looks like it's attempting to let Opera users through, when I visit the page with Opera 9.64 I get an "unsupported browser" message. If I change Opera's settings to report itself as Firefox, the page works perfectly! With that in mind, I'm pretty sure it's a problem with the script and not the browser.
Any jQuery experts have a suggestion?
You can replicate the behavior by visiting any book on Amazon and clicking the "look inside this book" link.
Prior to jQuery 1.3, you could use jQuery.browser:
if( $.browser.opera ){
alert( "You're using Opera version "+$.browser.version+"!" );
}
From version 1.3, you should use jQuery.support instead.
Main reason for this is that should should avoid checking for browsers, as features may change from version to version, making your code obsolete in no time.
You should always try to use feature detection instead. This will allow you to see if current browser supports the feature you're trying to use, regardless the browser brand, version, etc.
There is a special window.opera object which is present in all Opera 5+ browsers. So something as simple as:
if (window.opera && window.opera.buildNumber) {
// we are in Opera
}
would be enough.
I check for Opera like this:
if (/Opera/.test (navigator.userAgent)) // do something
Why would you want jQuery?
It is much better to detect javascript capabilities rather than browser userAgent.
ie DOM, XmlHttpRequest, eventing model (event.target vs event.srcElement), ActiveX, Java etc
By focusing on the API functions that you will require, rather than a target browser you will create a more robust set of scripts, and inevitably less special casing.
This link here at opera will probably tell you more
A very simple way from Opera themselves:
if (window.opera) {
//this browser is Opera
}
Source: http://my.opera.com/community/openweb/idopera/
The main reason why Amazon fails on Opera is because the send different code from the server side already... If you visit the same page with Firefox and then save that page and reopen it in Opera it works fine...
But they promised to fix that sometime in January...
I think this way is the best
if ( window.opera.version() == 12) {
}
This example check if opera version is 12. Very useful when I have problems with font-face in Opera.
I don't know for sure ( i never really check for opera anyway) but if the built-in jQuery functionality doesn't detect opera, may be a bug with the jQuery which needs to be fixed. I would suspect if that's the case, it should get resolved fairly quickly.
In current HTML5 times, you can also check for browser features instead often.
if (!window.FormData) { alert("xmlhttprequest L2 FormData interface not available"); }