- 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; | |
| } | |
| }()); |
@baxfx would be neat if you could show us a safari stacktrace then.
this is what a safari 12+ stacktrace looks like:
https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Error/Stack
this also confirms that this should work in safari 12+