Last active
February 7, 2018 19:22
-
-
Save MarcelKlammer/bcca34a4cc185806b45f8f9e5876b87d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head></head> | |
<body> | |
<div id="txt_stage_1">_1_</div> | |
<div id="txt_stage_2">_2_</div> | |
<div id="txt_error">_no_error_</div> | |
<script> | |
function initExample() { | |
document.getElementById("txt_stage_1").innerText = "stage 1: passing?"; | |
console.log("passed stage 1"); // works even if devtools are closed in Edge/IE11. | |
document.getElementById("txt_stage_1").innerText = "stage 1: passed: console.log: " + console.log; | |
try { | |
document.getElementById("txt_stage_2").innerText = "stage 2: passing?"; | |
var x = console.log; | |
document.getElementById("txt_stage_2").innerText = "stage 2: passing? x: " + x; | |
//var x = console.log.bind(this); // does not work, same TypeError. | |
x('passed stage 2'); // only works if devtools are open in Edge/IE11. | |
document.getElementById("txt_stage_2").innerText = "stage 2: passed: x: " + x; | |
} catch (e) { | |
// If devtools are not open a TypeError is thrown which hinders further execution | |
// of the function that is calling that x(). So wrapping an anonymous function around x | |
// will stop execution of the anonymous function, but the other code will continue to | |
// work. If no wrapping function is provided then x is in the scope of the rest of the | |
// module function and this script will stop execution when the TypeError is thrown. | |
document.getElementById("txt_error").innerText = "stage 3 error: " + e; | |
} | |
} | |
// IE11, closed devtools: | |
// stage 1: passed: console.log: | |
// function log() { | |
// [native code] | |
// } | |
// stage 2: passing? x: | |
// function log() { | |
// [native code] | |
// } | |
// stage 3 error: TypeError: Ungültiges aufrufendes Objekt. | |
// IE11, open devtools: | |
// stage 1: passed: console.log: function __BROWSERTOOLS_CONSOLE_SAFEFUNC(){try{return n(arguments)}catch(i){t(i)}} | |
// stage 2: passed: x: function __BROWSERTOOLS_CONSOLE_SAFEFUNC(){try{return n(arguments)}catch(i){t(i)}} | |
// _no_error_ | |
// Edge, open devtools: | |
// stage 1: passed: console.log: function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] } | |
// stage 2: passed: x: function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] } | |
// _no_error_ | |
// Edge, closed devtools: | |
// stage 1: passed: console.log: function log() { [native code] } | |
// stage 2: passing? x: function log() { [native code] } | |
// stage 3 error: TypeError: Ungültiges aufrufendes Objekt. | |
window.onload = initExample; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment