Tag: browsers
Passing variables to setTimeout in javascript
by Siu Lun on May.29, 2009, under Programming, Web
I’ve been working on a javascript menu effect today. I don’t use javascript enough to remember all the syntax, let alone browser support.
So anyway, I had to use setTimeout in order to delay effect changes for human interactions, but I had to pass a couple of variables. Now following some javascript tutorial sites my original code was like this:
setTimeout(function(a,b) { alert(a+'-'+b); }, 100, 'a input', 'b input');
This worked on Firefox 3 which is my standard dev platform.
When I decide to test on IE though, all I get is ‘undefined’ coming up.
A quick search on the net revealed that I need to actually do:
var a = 'a input';
var b ='b input';
setTimeout(function(){ alert_func(a,b) },100);
function alert_func(a,b){
alert(a+'-'+b);
}
to make it work on IE.
Note: Apparently we also need to do a = null; and b=null; after the alert_func(a,b) call in the inline function in order to avoid a IE memory leak. (Have not tested or confirmed myself)
Tested on: IE8 and IE8 with compatbility mode
Credit goes to: MakeMineATriple‘s blog and most of all the comments below it.
Firefox 3.5b4 review
by Siu Lun on May.03, 2009, under Mac, Web
The final beta release of Firefox 3.5. I’ve installed it on my Mac and having lived with it for a few days. I have actually noticed a speed improvement. Though, I think it will be short-lived.
Firefox has always been good and fast since it was released, but many people including myself, have defected to the likes of Chrome and Safari for normal web serving as Firefox has somehow become slower than a lot of other solutions out there. The reason I believe is because of add-ons. The new beta, after I tried it, is fast, but I think it’s because all my plugins currently does not work with it so they’re disabled.
I still use FF as my main browser on the Mac, but I use Chrome as my default on Windows. I’m actually hoping Chrome for the Mac will be released soon. I’ll only ever use FF for work due to the community support and add-ons avaliable.

