browser-detection

Detect iPad 3 in Ruby

点点圈 提交于 2019-12-08 05:40:05
问题 Is it possible to detect an iPad 3 (aka The new iPad) using ruby/rails? If so, how would I go about doing it? 回答1: You can detect the device but I do not think it is possible to detect device version. As far as I know, Apple provides a user agent string which appears as follows: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10 There is no machine version information in this string and I do not know

how to detect browser and OS in Java applet

倖福魔咒の 提交于 2019-12-08 02:44:57
问题 I'm working on a complex Java applet which runs well in Safari and in various browsers on Windows and Linux but has problems on Macintosh in Chrome and Firefox. For debugging, it would be really helpful if Java code could detect and report the browser, the browser version, the OS, and the OS version when there are errors. What is the easiest and most reliable way for Java to detect that info? This looks good, but requires Apache log4j, and I don't know if I can convince the team to run that:

Writing Conditional Code for Internet Explorer WITHIN a Javascript file

青春壹個敷衍的年華 提交于 2019-12-07 11:50:13
问题 I'd like to know if it's possible to write conditional javascript within a javascript file for Internet Explorer. i.e. something like this... if (is IE7) { do this } else { do this instead }); I know I can load a completely different script for IE using conditional comments in the head, but I only want to change a small piece of code and so loading a completely different sheet would be an 'expensive' way to do that. 回答1: If you are using jquery you code do this if ($.browser.msie && $.browser

PHP - Display messages to certain browsers

十年热恋 提交于 2019-12-07 07:53:26
问题 I've searched for this and everything I find is way more than I need. I've done this in JavaScript before, but I would really prefer using PHP. How would I go about displaying a message to my visitors, depending on which browser they're using? Example: IE User would see: "You're using Internet Explorer" Firefox User would see: "You're using Mozilla Firefox" I'm not exactly sure if there are other major browsers besides IE, Firefox, Chrome, Safari, and Opera. But I would at least want to have

What's a quick, pure javascript replacement for jquery.browser (removed in jquery 1.9)?

孤街浪徒 提交于 2019-12-07 06:04:08
问题 Yeah, I know that feature detection is preferable. I've got a case in my codebase where we are using $.browser.msie and $.browser.version to decide whether to render some CSS or not. The developer who wrote the code is no longer with us, and I don't fully understand exactly what kind of feature detection I should write here instead. As a quick fix, what's the shortest way to implement $.browser.msie and $.browser.version? 回答1: I'll just copy the code from jQuery 1.8.3. // Limit scope

Detect Lion (OS X 10.7) in javascript?

馋奶兔 提交于 2019-12-07 01:11:08
问题 Is there a way to detect if the operating system is OS X Lion or not in Javascript? Cheers! 回答1: The user agent of Safari (and also Firefox) in Lion is something like Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1) AppleWebKit/534.48.3 (KHTML, like Gecko) Version/5.1 Safari/534.48.3 There is "Mac OS X 10_7_1" in it - this indicates Lion (= Mac OS 10.7). See here: http://www.whatsmyuseragent.com/ You can read the user agent string using "navigator.userAgent" 回答2: http://www.quirksmode.org/js

HttpServletRequest#getHeader(“User-Agent”) returns null browser name

流过昼夜 提交于 2019-12-07 00:40:52
问题 I'm using Java 6. I have very less knowledge of JSP and Servlets. I'm using the following code to get browser name in which my application is running: String browserName = requestProvider.get().getHeader("User-Agent"); Also I'm using the following code to get IP address of the machine on which my application is running: String ipAdd = requestProvider.get().getRemoteAddr(); In both the cases requestProvider is a reference variable of type Provider<HttpServletRequest> . And I'm assured that it

How to detect if a user had javascript disabled?

这一生的挚爱 提交于 2019-12-06 08:17:28
问题 I was talking with a friend about users who do not have javascript enabled in their browser and what could be done to show them a "no-javascript" version of your website. Is it possible and how can it be done? Thoughts? 回答1: Don't try to build separate JS and non-JS versions of the site. Build a non-JS version and then enhance it with JS. This makes it easier to reuse code, allows you to use object/feature detection for the entire stack, and makes it less likely that users without JavaScript

PHP browser and os detection showing chrome instead of opera

China☆狼群 提交于 2019-12-06 08:12:42
I have a simple php script to detect browser name and os. Everything goes well, except for OPERA, that shows as Chrome. Here is my code: <?php $user_agent = $_SERVER['HTTP_USER_AGENT']; function getOS() { global $user_agent; $os_platform = 'Unknown OS Platform'; $os_array = array ( '/windows nt 6.2/i' => 'Windows 8', '/windows nt 6.1/i' => 'Windows 7', '/windows nt 6.0/i' => 'Windows Vista', '/windows nt 5.2/i' => 'Windows Server 2003/XP x64', '/windows nt 5.1/i' => 'Windows XP', '/windows xp/i' => 'Windows XP', '/windows nt 5.0/i' => 'Windows 2000', '/windows me/i' => 'Windows ME', '/win98/i'

Detection for Safari Windows with Javascript

a 夏天 提交于 2019-12-06 05:45:44
问题 How do I check if user is using Safari on the Windows? Because I need to apply some special styles to the site. 回答1: You can test navigator.userAgent for the strings Safari/ and Windows (list of Safari user agent strings), e.g.: Live Example var ua = navigator.userAgent.toLowerCase(); if (ua.indexOf("safari/") !== -1 && // It says it's Safari ua.indexOf("windows") !== -1 && // It says it's on Windows ua.indexOf("chrom") === -1 // It DOESN'T say it's Chrome/Chromium ) { // Looks like Safari on