Created
November 6, 2008 17:46
-
-
Save kangax/22653 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sourceIndex = (function(){ | |
var root = document.documentElement, | |
indexOf = Array.prototype.indexOf; | |
if ('sourceIndex' in root) { | |
if (root.sourceIndex === 0) { // Opera | |
return function(e) { | |
return e.sourceIndex + 1; | |
} | |
} | |
else if (root.sourceIndex === 1) { // IE | |
return function(e) { | |
return e.sourceIndex; | |
} | |
} | |
} | |
else if (indexOf && indexOf.call(document.getElementsByTagName('*'), document.documentElement) === 0) { | |
return function(e) { | |
return indexOf.call(e.ownerDocument.getElementsByTagName('*'), e) + 1; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment