quick tips can all go here

Friday, March 24th, 2006

Dean Edwards and Another Base.js

Category: JavaScript, Library, Tip

Dean Edwards is a smart man, and wasn’t happy with any Base classes out there in various libraries so he wrote his own Base.js. His goals: I want to easily create classes without the MyClass.prototype cruft I want method overloading with intuitive access to the overloaded method (like Java’s super) I want to avoid calling Read the rest…

Posted by Dion Almaer at 6:56 pm

3.7 rating from 47 votes

Thursday, March 9th, 2006

Eliminating redisplay flashes in JavaScript

Category: Articles, JavaScript, Tip

Patrick Fitzgerald has written up his technique for eliminating redisplay flashes in JavaScript. We all see this problem in various scenarios. Nice semantic HTML comes down before the CSS/JS has styled it. For a split second you see the ugly style before the true style is applied. Your first thought might be “I’ll just add Read the rest…

Posted by Dion Almaer at 11:13 am

3.4 rating from 22 votes

Friday, February 24th, 2006

ReCSS: Reload your CSS Bookmarklet

Category: CSS, Tip

David Schontzler came up with a quick and useful bookmarklet, ReCSS. It reloads all the stylesheets pulled in via links by adding a query string argument to the end of the URL. Quite handy for applying CSS tweaks to dynamic apps. Tested in Firefox, IE, and Safari.

Posted by Dion Almaer at 9:18 am
1 Comment

3.8 rating from 32 votes

Thursday, February 23rd, 2006

IE Tip: Cheeky way to see the current state of the page

Category: HTML, IE, Tip

Who needs debuggers and add ons, when you can simply put the following in your IE address bar: < View plain text > javascript javascript:'<xmp>’+window.document.body.outerHTML+'</xmp>’;

Posted by Dion Almaer at 10:21 am

3.8 rating from 89 votes

Tuesday, February 21st, 2006

Quick Tip: Text Truncation with JavaScript

Category: JavaScript, Tip

A random tip here. This snippet allows you to truncate a paragraph, and add a ‘…’ to the end of the truncation. When a user clicks on the ‘…’ it expands out to the full text. Truncate the text to a length of your choosing Do not truncate in the middle of a word (only Read the rest…

Posted by Dion Almaer at 8:01 am

3.4 rating from 56 votes

Thursday, January 26th, 2006

XMLHttpRequest and status code: 0

Category: Ajax, Tip

We run into quirks around the XHR object on various browsers and such. The naive approaches tend to have workarounds put in them, and you soon realise why frameworks like Dojo have the code they do. To make it work. Marko Samastur wrote about a little quirk, and the magic of status code 0. Have Read the rest…

Posted by Dion Almaer at 7:05 am

3.5 rating from 54 votes

Monday, January 23rd, 2006

JavaScript Tip: Cross Browser Cursor Positioning

Category: JavaScript, Tip

Beau Hartshorne has been burnt by a few pixels when getting the position of the users cursor cross browser. I discovered that IE’s clientX and clientY measurements were sometimes a couple pixels out. It turns out this is because IE’s the clientX and clientY measurements start from (2,2) in standards mode, and (0,0) in quirks Read the rest…

Posted by Dion Almaer at 12:28 am

3.6 rating from 75 votes

Wednesday, January 18th, 2006

Prototype adds CSS selector function: $$(‘div#page p.summary img’)

Category: Library, Prototype, Tip

Those prototype folks love their magic functions don’t they :) This time, Sam Stephenson has added some CSS selector magic to the Prototype trunk. Example: Find all elements inside elements with class “summaryâ€?, all inside the with id “pageâ€? and hide each matched tag: < View plain text > javascript $$(‘div#page p.summary img’).each(Element.hide); For fun, Read the rest…

Posted by Dion Almaer at 12:28 pm

4 rating from 94 votes

Tuesday, January 17th, 2006

JavaScript Tip: Watch out for “+”

Category: Examples, JavaScript, Tip

Dynamic languages are the cool thing du jour. All dynamic languages are not born equal, and JavaScript is one that happens to be weakly typed. This means that you can keep throwing new types at a variable and JavaScript takes it in its stride. You sometimes get into some problems though, and one of the Read the rest…

Posted by Dion Almaer at 12:21 pm

3.5 rating from 31 votes

Thursday, January 12th, 2006

JavaScript Tip: Running code in the dark

Category: JavaScript, Tip

At a recent client, we were finding strange behaviour occuring in the JavaScript side of the house. After taking a look, the problem was namespace collisions. A couple of the developers were new to JavaScript, and didn’t know about the scoping world. For example, the classic: var foo = “whee”; when placed at the top Read the rest…

Posted by Dion Almaer at 12:11 am

3.6 rating from 45 votes

Wednesday, January 4th, 2006

CSS Quick Tip: overflow: hidden; and IE

Category: CSS, Tip

I have run into the same issue with three projects in a couple of weeks. The issue is a common one, and it comes out as IE not listening to your CSS dimensions. For example, take this blog. We commonly attach images to our posts, and what if we post a large image? The rightbars Read the rest…

Posted by Dion Almaer at 2:50 pm

2.8 rating from 25 votes