Skip to content

Instantly share code, notes, and snippets.

@boodle
Last active June 26, 2020 10:44
Show Gist options
  • Save boodle/d5ae0477e091bbba8c66 to your computer and use it in GitHub Desktop.
Save boodle/d5ae0477e091bbba8c66 to your computer and use it in GitHub Desktop.
On screen debug window for debugging mobile devices

Add to the body of the page you want to inspect; it redirects js errors to a div attached to the bottom of the window:

<style type="text/css">
#debugWindow {
position:fixed;
display:block;
bottom:0;
left:0;
width:100%;
height:150px;
border:1px solid red;
background-color:#FFF;
overflow:scroll;
z-index: 10000;
}
</style>
<pre id="debugWindow"></pre>
<script type="text/javascript">
    let yerror = function(msg, url, linenumber) {
        $('#debugWindow').append(url+', line '+linenumber+String.fromCharCode(10)+msg+String.fromCharCode(10));
        return true;
    };

    window.addEventListener('error', yerror);
    window.console.log = function(msg) {
        $('#debugWindow').append(' # '+msg+String.fromCharCode(10));
    };
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment