Christian Heilmann

You are currently browsing the archives for the Tips & Tricks category.

Archive for the ‘Tips & Tricks’ Category

MSIE problems to watch out for when using animation libraries

Wednesday, June 14th, 2006

I had some issues with one of the code examples for the upcoming book. MSIE has a very annoying bug that when you use an opacity animation – for example with YUI or jQuery: When the element you want to fade in our out has no background colour, MSIE messes up the font for some reason. Another problem is that when you use jQuery for the fading, the element needs to have hasLayout set.

Check out the testcase

Fancy embedded web search for your web site? It’s easy as pie with JSON!

Saturday, June 10th, 2006

It is great if a company offers their data to developers to use on their own sites. It is even better when it is pretty painless to embed this data into your own products. Nearly all of the Yahoo! services also offer a REST API to use results of searches in your own web sites – the difference to a lot of other services is that you could also have the data in JSON format rather than XML.

What this means? You don’t really need any Ajax trickery to use the data, a simple SCRIPT tag is enough.

Find out more about Embedded Dynamic Web Search Forms with JSON

This will probably be a first in a series of tips and tricks with the Y! APIs.

Do you expect me to talk? Web Standards Group London Meetup on July the 14th

Thursday, June 8th, 2006

Scene from James Bond:Goldfinger You’ve read enough of my stuff, now it is time to see and hear me talk (if you are able to do both). This means not only will you be able to listen to some stuff I have to say, no, you can even ask questions and shout at me without risking comment moderation.

Stuart Colville of Muffinresearch has organised the first Web Standards Group London Meetup and I was asked to give a presentation on “something about modern JavaScript”. He also asked Andy Budd to talk about “something about CSS and web standards”.

Hence I pondered and came up with the idea to hold a concept/idea/tips and tricks session about “Maintainable JavaScript”. This means I’ll talk about how to create JavaScript that will not come back to you for maintenance but make it easy for colleagues, clients and other third parties to change the look and feel and even the content of your scripting solutions.

In any case, it’ll be an interesting evening and there’ll be book giveaways (with mine being released 3 days after the event) and drinks to make you forget what Andy and me talked about. So go to the site, sign up and I’ll see you on the 14th of July in London’s beautiful north (I can take a bus home, or cycle!).

Dynamic Code Viewing with jQuery

Monday, June 5th, 2006

Dabbling around with jQuery for the last chapter in my upcoming
book about JavaScript
, I realised it is dead easy to do something that really annoyed the hell out of me for a long time:

When you display code examples in online tutorials and you don’t want to use server side includes to show the code (as you want to offer the explanation page as documentation as well) you need to maintain the code in two locations: The code itself and the code examples in the documentation document.

Now, jQuery has these really cool methods to do easy AJAX calls, why not use them to pull in the code when the user clicks the link to the code?

The example page for jqueryCodeView shows the outcome and the script that makes it happen. Quite neat package, that.

Replace Pop-Ups with dynamic includes using DOMinclude (updated)

Thursday, May 25th, 2006

Update 25/05/06: DOMinclude now supports only one include window at a time and closing include windows from external files.

Pop-up windows are a pain for both the developer and the users. Often enough a page needs to link to a terms and conditions document and as the client does not want the user to leave the page you are asked to implement them in a pop-up.

The problem with this are technical and psychological:

  • years of unsolicited pop-up windows have conditioned users to immediately close windows when they open
  • the same reason and security concerns made people install pop-up blocker software and browsers to include pop-up blocking options, and depending on their configuration these may even block your “friendly pop-ups”.

One solution is to use JavaScript to create a new layer with the content of the document when JavaScript is available and simply link to the page when it isn’t.

DOMnclude is a script that does that for you

Following is an example what it does to a normal link when you add a certain CSS class. Enjoy, and kiss those pop-ups good-bye.

Update: Would people who have IFRAMES blocked please test the version that checks for blocked iframes? You should be sent to the page instead of trying to load the page into the layer when you click the “Amber Spyglass” link in the demo page. Please comment below if it works then I will include the fix.

DOMinclude example