Fix console.log in Chrome and Magento
<!-- Add to the package layout (via local.xml or however you prefer) --> | |
<!-- Also, best to remove before deployment, as some users report --> | |
<!-- it makes IE 7 crash --> | |
<default> | |
<reference name="content"> | |
<block type="core/text" name="fix.console" as="fix.console"> | |
<action method="setText"> | |
<text><![CDATA[<script type="text/javascript"> | |
iframe = document.createElement('iframe'); | |
iframe.style.display = 'none'; | |
document.getElementsByTagName('body')[0].appendChild(iframe); | |
window.console = iframe.contentWindow.console; | |
console.firebug = "faketrue"; | |
</script>]]></text> | |
</action> | |
</block> | |
</reference> | |
</default> |
This comment has been minimized.
This comment has been minimized.
Ah, that looks more right, it's a pretty hacky fix so I'm not surprised it broke since I first wrote it. Thanks for the fix to my fix. In case you're curious, the offending Javascript is in
|
This comment has been minimized.
This comment has been minimized.
in some version of IE8 I had the following error: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0) Timestamp: Tue, 7 Feb 2012 11:29:49 UTC Message: 'console' is null or not an object Line: 183 Char: 25 Code: 0 URI: Message: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917) Line: 0 Char: 0 Code: 0 URI: |
This comment has been minimized.
This comment has been minimized.
Adding an "if console" around the javascript in the text node should fix that. It sounds like you're using IE without any javascript debugger. |
This comment has been minimized.
This comment has been minimized.
thx, great snippet! but you need to comment it out after development. besides those errors in IE8 @guymoller mentioned, ie7 crashes completely. if (console) does not fix that. |
This comment has been minimized.
This comment has been minimized.
Thanks for the heads up, but I'm not sure I follow. If you're wrapping everything in an if(console), how does the code run in IE 7? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
@alan
In my Google Chrome "iframe.style = 'display:none';" did not work, iframe was visible. Changed it to "iframe.style.display = 'none';" and it worked.
P.S. Thanks for this great snippet. Really saved me :)