Archive for the ‘JavaScript’ Category

Simple JavaScript execution timer

/** * Simple JavaScript execution timer * http://programming.torensma.net * * Example: * scriptTimer.startTimer(); * alert(‘Hello world!’); * scriptTimer.stopTimer(); * alert(scriptTimer.scriptRunTime); */ var scriptTimer = {     scriptRunTime : 0,     startTime : 0,     stopTime : 0,     startTimer : function(){         time = new Date();     [...]

More »

window.onfocus and window.onblur not working in IE7

I recently created a script that detected if the browser window was still focussed. As long as it was focussed I repeatedly checked some things on the server via an Ajax call. All worked fine in Chrome and Firefox. But when I tested my script in IE7, the focus routine failed.After a little research I [...]

More »

Reflection in javascript

It’s a little known fact that javascript actually supports a type of reflection.With the for…in statement it’s possible to traverse items in an array, but also to traverse properties in an object. using the following snippet gives you an alert of the available properties in object var msg = “”; for (var item in _object_) [...]

More »