Christian Heilmann

You are currently browsing the archives for the Experiments category.

Archive for the ‘Experiments’ Category

Stupid Tricks with JavaScript

Friday, June 9th, 2006

Dude, check this out

This does not throw a syntax error. First one to see through my crazy trick can take a cookie from the jar in the kitchen!

The cookie goes to Matthew (check the comments).

Explanation: You can set labels in JavaScript (as explained in an earlier post) by adding a colon to a name, and all a URL does is create a label with the name ‘http’. As the double slash is following the colon, the JavaScript interpreter only recognises a label followed by a comment.

Gabbly.com in case you need to talk about a web site

Thursday, June 8th, 2006

Gabbly is a really interesting approach to the issue that you need to discuss designs with clients and peers. It is a chat panel that appears on any page (except for those that redirect the user) when you add the URL as a parameter, for example

http://www.gabbly.com/www.wait-till-i.com

It is a matter of time before there will be some legal issues with that (libel and all that), but is a really nice idea!

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

What APIs/Web Services do you use?

Wednesday, May 17th, 2006

I am starting the final chapter of my book at the moment (yay!) and it is “Using Third Party JavaScript”. In the chapter I will introduce some libraries and services to use and give examples how to do that (quick Google Map, Flickr stuff, using the REST APIs of Yahoo) and I wondered what other services you like using and why? I’d be especially interested in services that provide JSON objects or even code.

Thanks for your input!