You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
2.1 KiB

  1. // NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
  2. // IT'S JUST JUNK FOR OUR DOCS!
  3. // ++++++++++++++++++++++++++++++++++++++++++
  4. /*!
  5. * Copyright 2014-2015 Twitter, Inc.
  6. *
  7. * Licensed under the Creative Commons Attribution 3.0 Unported License. For
  8. * details, see https://creativecommons.org/licenses/by/3.0/.
  9. */
  10. // Intended to prevent false-positive bug reports about Bootstrap not working properly in old versions of IE due to folks testing using IE's unreliable emulation modes.
  11. (function () {
  12. 'use strict';
  13. function emulatedIEMajorVersion() {
  14. var groups = /MSIE ([0-9.]+)/.exec(window.navigator.userAgent)
  15. if (groups === null) {
  16. return null
  17. }
  18. var ieVersionNum = parseInt(groups[1], 10)
  19. var ieMajorVersion = Math.floor(ieVersionNum)
  20. return ieMajorVersion
  21. }
  22. function actualNonEmulatedIEMajorVersion() {
  23. // Detects the actual version of IE in use, even if it's in an older-IE emulation mode.
  24. // IE JavaScript conditional compilation docs: https://msdn.microsoft.com/library/121hztk3%28v=vs.94%29.aspx
  25. // @cc_on docs: https://msdn.microsoft.com/library/8ka90k2e%28v=vs.94%29.aspx
  26. var jscriptVersion = new Function('/*@cc_on return @_jscript_version; @*/')() // jshint ignore:line
  27. if (jscriptVersion === undefined) {
  28. return 11 // IE11+ not in emulation mode
  29. }
  30. if (jscriptVersion < 9) {
  31. return 8 // IE8 (or lower; haven't tested on IE<8)
  32. }
  33. return jscriptVersion // IE9 or IE10 in any mode, or IE11 in non-IE11 mode
  34. }
  35. var ua = window.navigator.userAgent
  36. if (ua.indexOf('Opera') > -1 || ua.indexOf('Presto') > -1) {
  37. return // Opera, which might pretend to be IE
  38. }
  39. var emulated = emulatedIEMajorVersion()
  40. if (emulated === null) {
  41. return // Not IE
  42. }
  43. var nonEmulated = actualNonEmulatedIEMajorVersion()
  44. if (emulated !== nonEmulated) {
  45. window.alert('WARNING: You appear to be using IE' + nonEmulated + ' in IE' + emulated + ' emulation mode.\nIE emulation modes can behave significantly differently from ACTUAL older versions of IE.\nPLEASE DON\'T FILE BOOTSTRAP BUGS based on testing in IE emulation modes!')
  46. }
  47. })();