Last active
December 17, 2015 05:08
-
-
Save AMHOL/5555467 to your computer and use it in GitHub Desktop.
Windows phone console
This file contains 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
if ( (typeof window.console == 'undefined' || typeof window.console.log != 'function') && !!window.location.href.match(/\?console=true/i) ) { | |
var ul = _createTag('ul', false, { | |
'line-height': '30px', | |
'background-color': '#fff', | |
'list-style-type': 'square', | |
color: '#000', | |
position: 'absolute', | |
top: 0, | |
right: 0, | |
left: 0, | |
'z-index': 9999 | |
}); | |
ul.appendChild(_createTag('li', { | |
innerText: 'Javascript Console' | |
}, { | |
'font-weight': 'bold', | |
display: 'block' | |
})); | |
window.console = { | |
log: function(logStr) { | |
ul.appendChild(_createTag('li', { | |
innerText: logStr.toString() | |
})); | |
} | |
}; | |
function _createTag(nodeType, attributes, style) { | |
var elem = document.createElement(nodeType); | |
if ( typeof attributes != 'undefined' && attributes ) { | |
for ( var key in attributes ) { | |
elem[key] = attributes[key]; | |
} | |
} | |
if ( typeof style != 'undefined' && style ) { | |
for ( var key in style ) { | |
elem.style[key] = style[key]; | |
} | |
} | |
return elem; | |
}; | |
var eventListener = (function() { | |
if ( typeof window.addEventListener != 'undefined' ) { | |
return 'addEventListener'; | |
} else if ( typeof window.attachEvent != 'undefined' ) { | |
return 'attachEvent'; | |
} | |
})(); | |
window[eventListener]('load', function() { | |
document.body.appendChild(ul); | |
}); | |
window.onerror = function(msg, url, line) { | |
console.log('Error: '+ msg +' on line: '+ line + ' in ' + url); | |
return true; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment