browser-detection

Javascript - detect if event lister is supported

冷暖自知 提交于 2019-11-29 02:34:56
问题 Is it possible to detect if certain events are supported in certain browsers? I can detect if the browser supports document.addEventListener, but I need to know if it supports the event DOMAttrModified. Firefox and Opera support it, but Chrome and others do not. Thanks if anyone can help! 回答1: Updated answer : Yes , you can feature-detect this. Create an element, listen for the event, and change an attribute on the element. In my tests, you don't even have to add the element to the DOM tree,

Is server-side user agent detection/sniffing bad?

社会主义新天地 提交于 2019-11-29 02:26:16
问题 Client-side user agent detection is known to be bad and discouraged in favor of feature detection. However, is it also bad to react differently based on the incoming user agent field in a HTTP request? An example would be sending smaller or larger images based on whether the incoming user agent is mobile or desktop. 回答1: I think it depends what your motivation is. For example, in the mobile web sector what you are attempting to do is provide the user with something that looks sensible on

How to find out about the User Agent in GWT

♀尐吖头ヾ 提交于 2019-11-29 01:14:08
I am trying to write browser specific code. Is there a GWT API to find out which browser the client is using? The GWT Developer's Guide page on Cross-Browser Support gives a JSNI function that returns the UserAgent string. Note, however, that you probably want to use Deferred Binding to write browser-specific code, instead of detecting the UserAgent. Edit: Kasturi points out Window.Navigator.getUserAgent() , which is implemented like so: /** * Gets the navigator.appName. * * @return the window's navigator.appName. */ public static native String getAppName() /*-{ return $wnd.navigator.appName;

How do I detect IE and Edge browser?

时光总嘲笑我的痴心妄想 提交于 2019-11-28 19:15:11
Can't get Parallax working properly in IE or Microsoft Edge. I've looked in forums and haven't found a solution to the problem. I've come up with hopefully a solution for now. I want to make a message appear if the user is using IE or Edge. Not sure how I can detect that the browser being used is one or the either. Here is some javascript code I'm trying to work with: <script src="https://github.com/ded/bowser/blob/master/src/bowser.js"></script> // Determine Browser Used browser = require('bowser').browser; becomes browser = require('bowser'); if (bowser.msie || bowser.msedge) { alert('Hello

Browser & version in prototype library?

帅比萌擦擦* 提交于 2019-11-28 18:25:28
I am used to using Atlas. Recently i have started transitioning to jQuery and sometimes prototype. The project that i'm currently working on is using prototype. In Prototype, is there an easy way to get the browser name and version? I've looked over the API documentation and can't seem to find it. As a completion to nertzy's answer you can add the ability for detecting IE versions using this: Prototype.Browser.IE6 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 6; Prototype.Browser.IE7 = Prototype.Browser.IE && parseInt(navigator

Zepto fallback to jQuery

China☆狼群 提交于 2019-11-28 17:11:26
问题 I'm using ZeptoJS for my web app, but I'd like to fall back to jQuery if the browser doesn't support Zepto. Since IE is the only major browser not supported at the moment, I'm tempted to detect IE: if(navigator.appName == 'Microsoft Internet Explorer'){ // load jquery } else { // load zepto } but I'd prefer to specificly detect Zepto support and use jQuery in other cases. Is there a feature detection way to do this? 回答1: This might be a crazy idea (I'm not sure if Zepto will even load on an

Mobile Device Browser File vs. WURFL for ASP.NET

风流意气都作罢 提交于 2019-11-28 16:52:39
问题 I am working on a commercial web application that has a separate mobile browser version intended for the more capable devices (BlackBerry, iPhone, Android, etc). I don't want to do simple User Agent contains style logic and was looking at the various detection libraries. It seems like WURFL and Mobile Device Browser File are my best options. The Mobile Device Browser File (MDBF) project at CodePlex exposes information through the Request.Browser property. Also, it has a Microsoft Public

What is better: CSS hacks or browser detection?

自古美人都是妖i 提交于 2019-11-28 15:54:14
Commonly when I look around the Internet, I find that people are generally using CSS hacks to make their website look the same in all browsers. Personally, I have found this to be quite time consuming to find all of these hacks and test them; each change you make you have to test in 4+ browsers to make sure it didn't break anything else. About a year ago, I looked around the Internet for what other major sites are using (Yahoo, Google, BBC, etc) and found that most of them are doing some form of browser detection (JS, HTML if statements, server based). I have started doing this as well. On

server-side browser detection? node.js

↘锁芯ラ 提交于 2019-11-28 14:00:52
问题 Most implementations i've seen are for browser detection on the client side. I was just wondering if it was possible to do browser detection before sending any resources to the client. Thanks. 回答1: var ua = request.headers['user-agent'], $ = {}; if (/mobile/i.test(ua)) $.Mobile = true; if (/like Mac OS X/.test(ua)) { $.iOS = /CPU( iPhone)? OS ([0-9\._]+) like Mac OS X/.exec(ua)[2].replace(/_/g, '.'); $.iPhone = /iPhone/.test(ua); $.iPad = /iPad/.test(ua); } if (/Android/.test(ua)) $.Android =

I need an easy way to detect CSS3 media query support using jquery

*爱你&永不变心* 提交于 2019-11-28 12:27:25
I need a quick and dirty way to detect media query support using jquery. I defined a function as follows: function mediaQueriesEnabled () { var v = parseFloat($.browser.version); if ($.browser.msie) { if (v < 9) return (false); } return (true); } Can someone help me fix this up a bit? Looking at this page: http://caniuse.com/css-mediaqueries I realized that there are some complexities here. For example, when I test my version of safari, I get "534.57.2". I want to avoid installing modernizr for now, mainly because I'm in a crunch and I need to handle most situations in the short term. Any help