From 5ddfad8a6275b1f0c73c15f9bfd3ed4269ba59bf Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Thu, 17 Jul 2008 15:22:18 -0500 Subject: [PATCH] Use different tactic to sniff for Opera in order to avoid false positives in IE. [#176 state:resolved] --- CHANGELOG | 2 ++ src/dom.js | 2 +- src/prototype.js | 8 +++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2b0dbcc..dcf3fca 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Use different tactic to sniff for Opera in order to avoid false positives in IE. [Tobie Langel, jddalton] + * Rename variable in Form.Element.Serializers.select. (jddalton) * Coerce Opera's version string into a number whenever we need to sniff. (Sam Holman, jddalton) diff --git a/src/dom.js b/src/dom.js index 07ef2d6..89e17ee 100644 --- a/src/dom.js +++ b/src/dom.js @@ -457,7 +457,7 @@ Element.Methods = { element.style.position = 'relative'; // Opera returns the offset relative to the positioning context, when an // element is position relative but top and left have not been defined - if (window.opera) { + if (Prototype.Browser.Opera) { element.style.top = 0; element.style.left = 0; } diff --git a/src/prototype.js b/src/prototype.js index d0a874c..2b0655e 100644 --- a/src/prototype.js +++ b/src/prototype.js @@ -4,10 +4,12 @@ var Prototype = { Version: '<%= PROTOTYPE_VERSION %>', Browser: { - IE: !!(window.attachEvent && !window.opera), - Opera: !!window.opera, + IE: !!(window.attachEvent && + navigator.userAgent.indexOf('Opera') === -1), + Opera: navigator.userAgent.indexOf('Opera') > -1, WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, - Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1, + Gecko: navigator.userAgent.indexOf('Gecko') > -1 && + navigator.userAgent.indexOf('KHTML') === -1, MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) },