browser-detection

Browser sniffing

倖福魔咒の 提交于 2019-12-06 04:43:05
问题 I know browsersniffing is not the correct way to design a site for multiple browsers. My question however is not related to designing a site which behaves well for each browser. I want to offer the user the ability to install the site as a webapp if the browser is Google Chrome or Firefox 4+, as a widget if it's Opera, as an extension if it's Safari... and so on Basically I want to slide in a div with a button offering this kind of install. There is no use showing the webapp solution if the

How to detect a browser that dosen't render .png transparency

孤者浪人 提交于 2019-12-05 21:16:40
I have this code that render's a image acording to the day of the week. But in IE6 and lower and probably some other browsers it won't render png opacity. So I want to change it a litle so that it will detect the browser's that don't render alpha transparency and tell them to load this image instead: "img/horarios2.png". Ive tried making it so that it would rule out IE6 and lower that are known for not rendering, but then I thinking about all the other browsers that I probably don't know about that don't render either and needed something that would rule them out also. I don't know the best

Writing Conditional Code for Internet Explorer WITHIN a Javascript file

半腔热情 提交于 2019-12-05 19:55:40
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. If you are using jquery you code do this if ($.browser.msie && $.browser.version == '6.0') { //do IE specific code } When writing Javascript, doing feature detection is always the

How can I detect kindle fire with javascript?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 17:42:42
问题 I'm trying to detect with javascript if my website is running on a kindle fire mobile device. I've tried with navigator.userAgent and navigator.appVersion but I get this results on kindle : 5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 and Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 What can I use form those strings to know that I'm on a kindle and

What is the correct way to detect Opera using jQuery?

余生颓废 提交于 2019-12-05 15:02:20
问题 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

How should I be setting browscap.ini file

点点圈 提交于 2019-12-05 11:55:20
问题 I downloaded the browscap.ini file and then pasted it to the directory "C:\wamp\bin\php\php5.4.3\extras" and i went to php.ini file and made these changes there: [browscap] ; http://php.net/browscap browscap = extras/browscap.ini and then i restarted the server, and typed the following code into temp.php file: <?php echo $_SERVER['HTTP_USER_AGENT'] . "<br><br>"; $browser = get_browser(null, true); print_r($browser); ?> now the output is like: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.4

Show a message if the browser is not internet explorer 9 or greater

折月煮酒 提交于 2019-12-05 09:59:29
问题 I would like to show my users a bar that looks like this, if: Browser is not IE; or Browser is IE but is version 8 or earlier (Note that the screenshot is just for illustration - IE 9 is supported for my site.) I found this nice jQuery plugin, but I don't want to use popups. http://jreject.turnwheel.com/ The site where I will implement this is a Sharepoint 2013 site, so I will use a content editor webpart to include the HTML content you provide and the bar should be at the top of everything

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

家住魔仙堡 提交于 2019-12-05 09:42:30
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? I'll just copy the code from jQuery 1.8.3 . // Limit scope pollution from any deprecated API (function() { var matched, browser; // Use of jQuery.browser is frowned upon. //

Detect if browser has smooth scrolling feature already

跟風遠走 提交于 2019-12-05 05:52:33
I have added smooth scrolling to a site of mine using this piece of JavaScript when clicking on hash links. $('a[href*=#]') .click(onAnchorClick); function onAnchorClick(event) { return ! scrollTo(this.hash); } function scrollTo(target) { var e = $(target); var y = e.exists() ? e.offset().top : 0; if(y == 0 && target != '#top') return false; if(Math.max($('html').scrollTop(), $('body').scrollTop()) != y) $('html,body') .animate({scrollTop: y}, 500, function() { location.hash = target; } ); else location.hash = target; return true; } $.fn.exists = function() { return this.length > 0 ? this :

Detect Lion (OS X 10.7) in javascript?

限于喜欢 提交于 2019-12-05 05:40:32
Is there a way to detect if the operating system is OS X Lion or not in Javascript? Cheers! 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" http://www.quirksmode.org/js/detect.html BrowserDetect.OS I don't know its compatibility though. <- This link does use the useragent. 来源: https: