Tip


quick tips can all go here


Monday, November 12th, 2007

Get rid of the IE iframe “click”

Category: IE, JavaScript, Tip

I am sure you have run into this before. You are on a site, interacting with a single page app, and then you hit the back button and IE clicks at you. The navigation “click” happens with iframes, and be a nuisance if you are trying to use iframes in a non-navigational way. Julien Lecomte Read the rest…

Posted by Dion Almaer at 7:33 am
13 Comments

++++-
4.1 rating from 30 votes

Tuesday, October 23rd, 2007

FitFlash: Make that rectangle move

Category: Flash, JavaScript, Library, Tip

You have seen the pain when you resize a browser and the Flash rectangle doesn’t move. FitFlash is a smart script that resizes your flash automatically if your browser window size is smaller or greater than your flash minimum desired size keeping it accessible independent of screen resolution. It is trivial to use, you just Read the rest…

Posted by Dion Almaer at 5:04 am
3 Comments

+++--
3.7 rating from 34 votes

Friday, October 19th, 2007

jQuery Logging

Category: jQuery, Library, Plugins, Tip

Dominic Mitchell has created a mini jQuery logging plugin that ties Firebug to the call chain. This means that if you are debugging something you can quickly add a .log(“….”) in the chain: < View plain text > javascript jQuery.fn.log = function (msg) {       console.log("%s: %o", msg, this);       return Read the rest…

Posted by Dion Almaer at 11:05 am
11 Comments

+++--
3.1 rating from 105 votes

Relative URLs as //ajaxian.com

Category: HTML, Tip

I had never thought to use relative URLs that are just relative to the protocol scheme as Ned Batchelder explains in his post on Http-https transitions and relative URLs. < View plain text > HTML <img src=’//fast.cdn.net/pix/smiley.jpg’ /> Who knew.

Posted by Dion Almaer at 11:00 am
6 Comments

+----
1.8 rating from 128 votes

Friday, October 12th, 2007

Testing JavaScript Objects with Function.prototype.call and Crosscheck

Category: JavaScript, Testing, Tip

Jason Harwig has written a quick tip on Testing JavaScript Objects with Function.prototype.call. The example that he uses is: < View plain text > javascript /**  * Call a function with the given execution context and parameters.  * @param <object> instance the object to use as the "this" inside the function  * @param <array of Read the rest…

Posted by Dion Almaer at 7:55 am
5 Comments

+++--
3.5 rating from 26 votes

Wednesday, October 3rd, 2007

Optimized Speedy Ajax Code

Category: Ajax, JavaScript, Tip

Dustin Diaz has revisited his seven JavaScript techniques and has updated his XHR-getting-function to be faster, using the Lazy Function Definition Pattern, which ends up looking like: var asyncRequest = function() { function handleReadyState(o, callback) { if (o && o.readyState == 4 && o.status == 200) { if (callback) { callback(o); } } } var Read the rest…

Posted by Dion Almaer at 8:53 am
10 Comments

+++--
3.8 rating from 38 votes

Wednesday, September 26th, 2007

More fun with DOMContentLoaded

Category: JavaScript, Tip

It is amazing how much chatter we have about wanting to know when the darn DOM is ready, and finding the right place to start doing your work. We just posted about IEContentLoaded and already Stuart Langridge has taken that and the other approaches and come up with this 7 liner (if you aren’t using Read the rest…

Posted by Dion Almaer at 11:30 am
23 Comments

+++--
3 rating from 25 votes

Friday, September 21st, 2007

Finding ‘send’ in JavaScript

Category: JavaScript, Tip

Ola Bini found send in JavaScript and it was a surprise for a bunch of people. To call a method on a function you use (). You could get the function object via the ‘.’ notation, or the array access method. This is why it makes sense that given: < View plain text > javascript Read the rest…

Posted by Dion Almaer at 1:18 am
37 Comments

++---
2.2 rating from 59 votes

Monday, August 20th, 2007

Wot no magnifying glass?

Category: iPhone, Tip

We have heard this a couple of times now, so thought that we should post it as a quick tip. Why does the magnifying glass not show in my app? It turns out that if you set user-scalable=0 in the meta tag, the magnifying glass doesn’t show for input type=”text” fields. It does still work Read the rest…

Posted by Dion Almaer at 12:19 am
7 Comments

++---
2.8 rating from 34 votes

Thursday, June 14th, 2007

Ajax, javascript and threads : the final truth

Category: Articles, Tip

Dan Simard has been writing about threading and JavaScript and came up with his Final Truth. Dan has an example that has a long running function that fires of an XHR request at the beginning. Will that response come back when it is done, or will it wait for the method to complete. There are Read the rest…

Posted by Dion Almaer at 5:45 am
11 Comments

+++--
3.8 rating from 34 votes

Tuesday, May 15th, 2007

The One True Way to Open a Window in JavaScript

Category: JavaScript, Tip

Ryan Johnson shares his short tip on how to use JavaScript to open a window, letting users decide how they want to handle it, and supporting non-JavaScript clients: < View plain text > HTML <a href="your_link" onclick="window.open(this.href,’window_name’,’options’); return false;"></a> unobtrusively add on to an item: < View plain text > javascript $$(‘#mylink’).each(function(link) {   link.onclick Read the rest…

Posted by Dion Almaer at 1:18 am
22 Comments

+++--
3.5 rating from 91 votes

Thursday, April 19th, 2007

Fun Safari Bugs Episode 34

Category: Browsers, Tip, WebKit

Tobie Langel fearlessly deals with browser quirks so Prototype users will not have too. His latest battle revolves around a Regex bug that causes Safari to crash when the string is large. /(.)+/.test(string); They fixed the usage of this in some areas but still have issues with JSON sanitization. The good news is that WebKit Read the rest…

Posted by Dion Almaer at 7:19 am
5 Comments

+++--
3.4 rating from 14 votes

Wednesday, April 18th, 2007

Make the XHR abstraction shorter

Category: Ajax, Tip

In low-level land, the try/catch trick that Prototype uses was king for ‘most fun way to get the XHR object’. Nicolas Faugout has put his hat in the ring with: < View plain text > javascript if (!XMLHttpRequest) {   function XMLHttpRequest() {     return new ActiveXObject(‘Microsoft.XMLHTTP’);   } } This feels like the Read the rest…

Posted by Dion Almaer at 5:13 am
18 Comments

+++--
3.5 rating from 50 votes

Friday, April 6th, 2007

Update Firebug to 1.0.4

Category: Tip, Utility

Update — go get 1.04 — its a more robust fix for the security issue – read Joe’s comment here. Joe Hewitt has posted an update to Firebug that you should grab right away as it fixes a couple of issues and covers a 0-day security hole. The update has been published to addons.mozilla.org, so Read the rest…

Posted by Dion Almaer at 2:00 am
6 Comments

++++-
4.2 rating from 31 votes

Monday, April 2nd, 2007

Packer 3.0 and isMSIE hacks

Category: Tip, Utility

Dean Edwards has released Packer v3.0, one of the top utilities to squeeze your JavaScript like a lemon. respects Microsoft conditional comments new option to shrink variable and argument identifiers removed the special chars feature (except the ;;; feature which people seem to like) some bug fixes: packer no longer closes spaces between the +/- Read the rest…

Posted by Dion Almaer at 9:14 am
6 Comments

+++--
3.4 rating from 23 votes

Wednesday, March 21st, 2007

Auto copy to clipboard

Category: JavaScript, Tip

This is an ancient tip, but a good-y. Jeffrey Larson put together a little hack to do auto copy to clipboard in a cross browser way (i.e. failing back to Flash). It is the kind of thing that can easily be abused, and you can make your users mad (You just nuked something important out Read the rest…

Posted by Dion Almaer at 7:49 am
14 Comments

+++--
3.7 rating from 89 votes