Easy cross-browser compatibility with IE7.js 2008-01-08

I spent a lot of time testing cross-browser compatibility on the last site I did. My friend Frank of Ruby Fleebie is loosing hours trying to be compatible with Firefox and Internet Explorer. So, when I heard that a simple javascript file could help us in our work, I thought that it would be nice to share it with you.

Here it is : IE7.js version 2.0 (beta). Check out the demo page and start having fun again by worrying less with cross-browser compatibility.

I also started the Not tested in IE initiative. What is it? It is for developers who don't want to test if the page or site displays correctly in Internet Explorer©. You just add the following logo on your site and you're ready to go!

Not tested in IE initiative

I proudly announce you that I hate PHP is the first site that joined the initiative. Look at the bottom of the page for the logo.


Tablesorter 2.0 : Simple table sorter with jQuery 2008-01-07

Here's something we're always ask : “Can we see the list in the order we want?” In a programmer's language, it means that the client wants to be able to sort a HTML table by clicking on the header row. You have two choices : server-side or client-side. If you choose server-side, you'll have to query all the data to the DB with a different “ORDER BY” clause. That's not nice for your DB and your DBA will probably hate you. If you choose client-side, you'll have to write A LOT of code. That is not nice for your phalanges and they will probably hate you.

God finally sent us a third option : Tablesorter 2.0 (a jQuery plugin).

It's easy to use and it just works! Take a look at the simplest example possible and don't forget there's a lot more to do.


Ask Dan : More on javascript threading 2007-12-06

From time to time, I receive emails from desperate people who want help with their javascript problem. I also receive a lot of emails of people wanting to help me with my “manly problems”. It's very nice from them to care about me and I take time to reply to each of them but I don't have that kind of problem for the moment.

Stuart Cooper recently sent me a mail about threading in javascript and I turn to you, javascripters, to find the a solution for his problem. I sent the code on RefactorMyCode for refactorisation and they will automatically show up in the comments of this post (the site is an idea of Marc-André Cournoyer who is a very active developer from Montreal). Don't be afraid to think outside the box. The solution may be completly different from what is already written.


I am experience trying to create a “cover page” that runs a ping to remote servers.In my code I am using setInterval() to run repeating pings (artificially quickly at the moment, ie 10 seconds rather than 1 min) and display the results to browser. I have built my own XMLHttpRequest module (mainly as a learning exercise) and I don't believe it to be the source of my ills. I have read through your article and the behaviour of alert() and confirm() fits exactly with what I am seeing when I run the following code :[snippet]

function startup(){

setInterval(“pinger('live',0)”,10000); setInterval(“pinger('standby',1)”,10000); setInterval(“pinger('dev',2)”,10000); setInterval(“pinger('test1',3)”,10000); setInterval(“pinger('test2',4)”,10000); setInterval(“pinger('test3',5)”,10000); setInterval(“pinger('test4',6)”,10000);

}

function pinger(server,divit){

console=document.getElementById('pingdiv' + divit); console.innerHTML=''; sendRequest(“../php/pingsys2.php?target=” + server);

}

[/snippet]

(each server has its own named div to return to)

What I am seeing when I run this is the final pinger response from the callback and nothing else. I since added debugging into my XMLHttpRequest code so that it split out the server response progress.

[snippet]

readyXML=xmlReq.readyState;

[/snippet]

[snippet]

if(readyXML == 3){

data=“Serving …”;

}

if(readyXML == 2){

data=“Sent …”;

}

if(readyXML == 1){

data=“Opening …”;

}

[/snippet]

What I have observed is that when running the setInterval commands as above, all except the final request are “jammed” on readyState = 1 and appropriately responds with “Sending …”

however,

when I do the following (which is messy)

[snippet]

function startup(){

setInterval(“pinger('live',0)”,1000); alert(“something”); setInterval(“pinger('standby',1)”,10000); alert(“something”); setInterval(“pinger('dev',2)”,10000); alert(“something”); setInterval(“pinger('test1',3)”,10000); alert(“something”); setInterval(“pinger('test2',4)”,10000); alert(“something”); setInterval(“pinger('test3',5)”,10000); alert(“something”); setInterval(“pinger('test4',6)”,10000);

}

[/snippet]

Each response is absolutely spot on and will continue to generate pings correctly. So in this case the script alert interrupts are forcing the callback request to trigger, whereas without the alerts its only the last request that triggers a callback. I have also tried using artificial timeout loops instead of alerts (which generate the odd browser “script running slowly” message) but to no avail.

At the moment I am almost resigned to having to create individual events (like rollovers, though I would much prefer the ping initialisation to occur window.onLoad()) that trigger the setInterval() … which also seems to work fine.

I am hoping that you may have come across a way of forcing the XMLHttpRequest to respond without forcing alerts or confirms on the user, in the time since the last update to the article.


A new project - I hate PHP 2007-12-05

If you are javascripter, chances are that you must work with some back-end languages like ASP.NET, ColdFusion, Ruby On Rails or PHP. If you work with a back-end language, chances are that you become frustrated against it sometimes. That's why I created I hate PHP.

What is it?

I hate PHP helps you to evacuate your daily frustrations against the PHP language via Twitter. It's simple. You must tell your twitter username to I hate PHP (on the website) and then, send a direct message to the ihatephp twitter user in the following format : d ihatephp a thing that frustrates you in PHP.

Why against PHP?

I could have done it against a lot of languages because they all suck in their own special way. But the moment I was thinking about the project, I was working with PHP and I just kept sending IM messages to Frank (of Ruby Fleebie) to tell him about things that frustrated me in PHP. I just made it more “official” and now I tell it to the world via I hate PHP.

Subscribe to the RSS of I hate PHP!


Barcamp Montreal 3 and this site 2007-11-05

Like most of you already knew, I'm working with Frank Lamontagne of Ruby Fleebie on a project called TimmyOnTime. We had the chance to present it at the last Barcamp Montreal and it went… really bad! If you want to know more about the whole adventure (and have a good laugh), click here to read the story written by Frank. (By the way, I used a good ol' click here link just for the fun of it… I never did it before and frankly, I like it… almost…).

What happens with Javascript Kata?

I know, I have been negligent with site. It's really shameful to let a great site die and there's no one to blame but me. Why I did that? I could give hundreds of reasons but they would all be lies. I really don't know what happened.

I want to give another twist to JavascriptKata. I want to get back to a more tradional reference site because I don't like the concept of a technical blog after all. I want the articles to be more persistent, not just a post that everyone forget about after a while.

But, there would be a RSS feed too. I would announce new articles on the site. I would also use it to debate on tricky things about javascript and then make an article out of it.

I really would like to hear you about this idea, please comment!