PDA

View Full Version : Two very useful things for javascript coders.


DrDOS
09-20-2010, 11:21 PM
<script type="text/javascript">

//Alerts to errors.

window.onerror=function(msg, url, linenumber){var logerror='Error message: ' + msg + '. Url: ' + url + 'Line Number: ' + linenumber;alert(logerror);return false}

</script>
I put that block of code in all my page templates, it tells me where and often what a problem is. It has saved many an hour of troubleshooting because it lets me know right away.

The second important thing is what Firefox can do for you. It's the only browser I know of that lets you see the page that is generated by javascript. Open this page with Firefox:

http://ronbeau.50webs.com/utilities/escape-codes.html

Then go : View, Page Source and take a look.

Then right click on the body of the page and choose Select All, then right click again and choose View Selection Source. You can just click on the selection source to see the written code better. What a difference! I think you can see what a useful tool this is in reviewing and troubleshooting your code.

Kor
09-21-2010, 10:57 AM
Great! :rolleyes: You have re-discovered the wheel:

http://www.w3schools.com/jsref/event_onerror.asp