Tip


quick tips can all go here


Thursday, April 17th, 2008

Are you sure your unload handler is firing in IE?

Category: Browsers, IE, Tip

Johan Sörlin found that sometimes his unload event never fired in IE: We recently found a serious bug in IE where the unload event wouldn’t fire on a specific page we had on a site. After some bug tracking we found out that the unload event never fired since all the contents of the page Read the rest…

Posted by Dion Almaer at 10:52 am
9 Comments

++++-
4.1 rating from 22 votes

Thursday, February 28th, 2008

Every keystroke is a prisoner – a neat commenting trick

Category: JavaScript, PHP, Tip

My favourite kind of tutorial or trick are the ones that are very easy to do but make a lot of sense – you know the ones that make you slap your forehead and say “why didn’t I do that before?”. Dirk Ginader blogged about a commenting trick (in German) that is one of these. Read the rest…

Posted by Chris Heilmann at 3:57 am
16 Comments

+++--
3.9 rating from 45 votes

Tuesday, February 19th, 2008

Cursing with JavaScript: Three Random Tips

Category: Browsers, JavaScript, Tip

I ran across a few posts in a row in my news reader that were each mini tips that involved Prototype, Firefox, and IE. Prototype Custom Events Howard Lewis Ship is making sure that Tapestry 5 will have 50% more Ajax, and has been playing with Prototype. He found a nagging bug to do with Read the rest…

Posted by Dion Almaer at 7:02 am
2 Comments

+++--
3.3 rating from 19 votes

Monday, February 18th, 2008

Self Printing JavaScript Literals

Category: JavaScript, Tip

Are you ever sick of seeing Object get printed out when you try to output a variable to your console. Oliver Steele talks about Self Printing JavaScript Literals where you can clean that up with a toString: < View plain text > javascript function makeLiteral(name) {return {toString:function(){return name}}} var L1 = makeLiteral("L1"); var L2 = Read the rest…

Posted by Dion Almaer at 6:09 am
6 Comments

+++--
3 rating from 19 votes

Wednesday, February 13th, 2008

Crazy way to change third party scripts

Category: JavaScript, Tip

Paul Irish posted a crazy method for tweaking third party scripts. His problem was that he was using MultiMap (online Mapping API) and wanted to internationalize the information, but it was hard coded in the JavaScript. To get around the problem he does this: < View plain text > javascript // WARNING!!  This is such Read the rest…

Posted by Dion Almaer at 6:22 am
5 Comments

+++--
3.4 rating from 18 votes

Tuesday, February 12th, 2008

The parseInt gotcha

Category: JavaScript, Tip

Guyon Morée has posted the old chesnut parseInt gotcha, so I thought I should put it up here as a quick tip: I was working on some stuff in javascript which involved some date/string parsing when one morning it failed. “That’s weird, yesterday it worked fine!” After some debugging with FireBug I found parseInt() was Read the rest…

Posted by Dion Almaer at 5:11 am
25 Comments

++---
2.6 rating from 41 votes

Monday, January 28th, 2008

Graceful Degradation of Firebug Console Object

Category: Debugging, JavaScript, Tip

Paul Irish saw the following graceful degradation of Firebug code in the Yahoo! media player: // code yanked from the Yahoo media player. Thanks, Yahoo. if (! (“console” in window) || !(“firebug” in console)) { var names = [“log”, “debug”, “info”, “warn”, “error”, “assert”, “dir”, “dirxml”, “group” , “groupEnd”, “time”, “timeEnd”, “count”, “trace”, “profile”, “profileEnd”]; Read the rest…

Posted by Dion Almaer at 6:37 am
11 Comments

++++-
4.7 rating from 339 votes

Friday, January 25th, 2008

Sexy JavaScript?

Category: JavaScript, Tip

How can you not post something called Sexy JavaScript? < View plain text > javascript // Sexy JavaScript // runs assertNotNull(iframeElement) in IE, otherwise assertNull(iframeElement) // taken from test code for http://yura.thinkweb2.com/scripting/contextMenu/   testShimExists: function() { with(this) {   this[Prototype.Browser.IE ? ‘assertNotNull’ : ‘assertNull’](iframeElement); }},

Posted by Dion Almaer at 1:27 am
7 Comments

++---
2.1 rating from 61 votes

Thursday, January 3rd, 2008

window.onload: another solution to get it going

Category: JavaScript, Tip

The solutions for getting real DOMContentLoaded across the various browsers keep on rolling in. The first one of the new year involves using the IE HTC feature and differs from others due to: document.write and conditional JavaScript comments try() catch() and doScroll having a separate file for IE This solution uses Microsoft’s proprietary HTC feature. Read the rest…

Posted by Dion Almaer at 5:09 am
Comment here

++---
2.8 rating from 26 votes

Tuesday, December 18th, 2007

JScript 5.7: Fixing IE6

Category: IE, Performance, Tip

Erik Arvidsson lets us know about the JScript 5.7 patch that is zooming out to IE6 users: The JScript 5.7 patch is now being pushed to an IE6 computer near you… IE6 uses Jscript 5.6 which has some serious design flaws when it comes to garbage collections. This by itself prevented us from releasing Gmail Read the rest…

Posted by Dion Almaer at 7:53 am
17 Comments

++++-
4.2 rating from 42 votes

Working aroung the instanceof memory leak

Category: JavaScript, Tip

Gino Cochuyt spent some hours to find the cause of memory leaks in IE when using instanceof. He found at least 3 Objects that cause the memory leaks: window document element Just using – if (window instanceof Object) – for example causes a memory leak! that grows by 50 KB per refresh; the reason for Read the rest…

Posted by Dion Almaer at 2:50 am
21 Comments

+++--
3 rating from 22 votes

Friday, December 14th, 2007

The problem with innerHTML

Category: Articles, JavaScript, Tip, Yahoo!

Some like to DOM their way around. Others prefer the simplicity of innerHTML. Julien Lecomte, of Yahoo!, wrote up his thoughts on the problems with innerHTML. Julien first points out some issues: Improper handling of the innerHTML property can enable script-injection attacks on Internet Explorer when the HTML string contains a script tag marked as Read the rest…

Posted by Dion Almaer at 7:41 am
18 Comments

+++--
3.8 rating from 72 votes

Tuesday, December 11th, 2007

Sucking in Dojo, YUI, or jQuery into any page

Category: JavaScript, Tip

Gareth Rushgrove has been having fun with Jash, the cross browser shell (if you miss Firebug as you are in Safari land, give it a go) and has bookmarklets that allow you to debug web pages with jQuery or Dojo, or YUI. Suck in your framework of choice, and start dinking around on the fly.

Posted by Dion Almaer at 6:18 am
2 Comments

+++--
3.9 rating from 30 votes

Friday, December 7th, 2007

Making sure you get new instances in JavaScript

Category: JavaScript, Tip

John Resig has posted on simple class instantiation, which delves into the nasty little bug that people can run into: < View plain text > javascript var foo = User(…); // forgot to use the "new" operator The magic “new” changes the scoping, allowing “this” to do the right thing. John walks through an example, Read the rest…

Posted by Dion Almaer at 2:45 am
19 Comments

++---
2.7 rating from 49 votes

Wednesday, November 28th, 2007

Safari CSS Reference

Category: CSS, Tip, WebKit

Do you want to have one place that tells you about all of the Safari properties? Now we have it. The reference shows not only the standard properties and how Safari handles them, but also all of the -webkit-* properties such as -webkit-border-top-right-radius:

Posted by Dion Almaer at 6:49 am
9 Comments

+++--
3.3 rating from 23 votes

Friday, November 23rd, 2007

Avoid unnecessary Ajax traffic with session state

Category: Ajax, JavaScript, Tip

David Mertz has written an article on avoiding unnecessary Ajax traffic with session state, which discusses RESTful techniques to minimize traffic, and how you can tweak your XHR code to be watchful. Basically, use 304 please! This tip presented some server code written in Python, but almost the same design would apply for nearly any Read the rest…

Posted by Dion Almaer at 2:38 am
3 Comments

+++--
3.3 rating from 32 votes