JavaScript


I spent hours trying to figure out why even the simplest code won’t run on Internet Explorer. I always got the “Object doesn’t support this property or method” error. I’ve even tried both innerHTML and DOM, and still, IE isn’t happy. After those long hours, I found a simple fix that works.

I got more and more curious because I’ve written another page (4 chained drop down list) with xajax and it run flawlessly on either Firefox, Internet Explorer and Opera. Tired of looking my codes, I decide to try something simple on a separate page.


...
$objResponse->addScript("alert('a');");
...

But it still won’t work. Luckily (and why this idea doesn’t came in the first place), I use the Web Developer Toolbar on Firefox, where you could just click Infomation > View Javascript. Trying to found the line where IE mention the error. After removing some unused lines, i found the suspect.


Line 954: for (i=0; i<xml.childNodes.length; i++)

Uninitialized variable ‘i’. After simply changed the code to:


Line 954: for (var i=0; i<xml.childNodes.length; i++)

It’s now up and running, on IE too. Hope this post may help others with similar problem and save others time of digging for the bug. I’ve also sent this topic to the xajax Forums, you can discuss it there, too. Happy Coding!

Sudahkah Anda mencoba Google Suggest (Beta)? Google Suggest adalah sebuah fitur baru dari Google yang memang masih dalam tahap beta namun bagi saya fitur ini sangat menyenangkan (dalam taraf tertentu). Sebuah fitur di mana akan muncul saran-saran pencarian seiring dengan diketikkannya huruf-huruf. Hal ini dimungkinkan dengan JavaScript yang aktif mengambil data dari server. Yang lebih mengesankan, yang saya ketahui setelah membaca tulisan dari Chris Justus, yang berjudul Google Suggest Dissected…, ternyata kode JavaScript nya bahkan menangani penyimpanan lokal untuk data yang telah diambil, sehingga ketika seseorang menekan backspace, tidak perlu lagi mengambil data ke server. Lebih lengkapnya, bisa dibaca di Google Suggest Dissected…, termasuk penjelasan langkah demi langkah dari kode yang digunakan oleh Google Suggest. Terimakasih pada Chris Justus yang telah membantu untuk memahami rahasia di balik kekuatan Google Suggest.

Selama beberapa waktu yang lalu, bila Anda mengunjungi situs ini dengan Internet Explorer, Anda akan mendapati tampilan yang kacau balau. Meskipun demikian, tidak ada masalah apapun bila dikunjungi dengan Mozilla Firefox. Setelah memiliki waktu luang, saya mencari-cari penyebabnya dan mendapati suatu keanehan yang sederhana. (more…)

I would like to add Yahoo! Messenger Online Presence to my page, but I want the status to be more informative. The status (I think) should be an image with appropriate text alternative (whether I’m online or not online) with an appropriate link too (going nowhere when I’m offline, and starting Y!M conversation when I’m online). So I decided to create an additional service (it still depends on Yahoo!Messenger’s Online Presence Service) to wrap the existing one. Nice isn’t it? Wanna use that service too? You simply need to add this code on your page:

<span id="rdcYahooStatus"><script type="text/javascript" src="http://services.riyono.com/yahoostatus.js?.usr=Your Yahoo!ID&amp;.name=Your Name"></script></span>

If the visitor disabled javascript or using an old browser, they will not be able to see your status, but your page should still rendered flawlessly (like it was before you add the code).

By using the service, you agree and understand that I may change or modify the terms and conditions of the service anytime. Please drop me an email at <nick at this domain> if you want to be notified when there are any changes.

Kemaren lagi iseng-iseng mau posting malah liat ada bookmarklet untuk quickpost. Jadi penasaran apa sih sebenernya bookmarklet itu dan gimana cara kerjanya. Akhirnya setelah beberapa menit utak atik, isinya cukup sederhana. Kalau mau, coba deh bookmark hasil utak atikku. Mempermudah orang yang pengen tau tentang ‘Walikan’ dan membuatnya pun cukup sederhana. (more…)