- IE10
- Firefox
- Chrome
- Safari
- Opera
Based off some code I wrote for asynchronous document.write.
Based off some code I wrote for asynchronous document.write.
| /* Script location finder | |
| * 2014-04-30 | |
| * | |
| * By Eli Grey, http://eligrey.com | |
| * License: X11/MIT | |
| */ | |
| /*! @source https://gist.github.com/eligrey/5426730 */ | |
| var current_script_location = (function() { | |
| var | |
| filename = "fileName" | |
| , stack = "stack" | |
| , stacktrace = stack + "trace" | |
| , loc | |
| , matcher = function (stack, matchedLoc) { | |
| loc = matchedLoc; | |
| } | |
| ; | |
| try { 0(); } catch (ex) { | |
| if (filename in ex) { // Firefox | |
| loc = ex[filename]; | |
| } else if (stacktrace in ex) { // Opera | |
| ex[stacktrace].replace(/called from line \d+, column \d+ in (.*):/gm, matcher); | |
| } else if (stack in ex) { // WebKit, Blink, and IE10 | |
| ex[stack].replace(/at.*?\(?(\S+):\d+:\d+\)?$/g, matcher); | |
| } | |
| return loc; | |
| } | |
| }()); |
haha
Does not work on Safari 12+
@baxfx would be neat if you could show us a safari stacktrace then.
this is what a safari 12+ stacktrace looks like:
TypeError: undefined is not an object (evaluating 'this.tech_[a]')
at techCall_(/js/video.min.js:17:27493)
at volume(/js/video.min.js:17:29255)
at ? (/js/w0bmscript.js:17:396)
at ? (/js/video.min.js:14:6728)
at forEach([native code])
at ? (/js/video.min.js:14:6709)
at d(/js/raven.min.js:2:6422)
https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Error/Stack
this also confirms that this should work in safari 12+
Really nice :)