I would like to know why the follow code doesn't work in the Google Chrome:
// creates a xss console log var cl = ( typeof( console ) != 'undefined' ) ? console.log : alert; cl('teste');
output: Uncaught TypeError: Illegal invocation
thanks.
https://groups.google.com/a/chromium.org/d/msg/chromium-bugs/gGVPJ1T-qA0/F8uSupbO2R8J
Apparently you can also defined log:
log = console.log.bind(console);
and then the line numbers also work
When you write cl();
, you're calling log
in the global context.
Chrome's console.log
doesn't want to be called on the window
object.
Instead, you can write
cl = function() { return console.log.apply(console, arguments); };
This will call log
in the context of console
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With