JavaScript

Preview image inline before uploading.

I hope HTML5 and Google Gear could do this thing better :-)
http://hedgerwow.appspot.com/image-upload-preview/demo.html

JavaScript
image

Comments (0)

Permalink

JOT: The JavaScript Object Template

http://code.google.com/p/jot-project/wiki/SyntaxAndHowTos :-) , still beta.

Hope you’d like it.

JavaScript

Comments (0)

Permalink

Found a new JS pattern from MSDN.

One day, I was trying to detect whether an element is an element that has no close tag.
So I did this:

var tagName = el.tagName.toLowerCase();
if( tagName == ‘img’ || tagName == ‘br’ || tagName == ‘input’  || tagName == ‘embed ‘ ){
// This is just a example, not all single tags are tested. These tags are :
// area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed.
// Do something here.
}

Well, this is not that efficient to write your program.
So I switch to use a string map, which is rather simple and John Resig uses the same trick in his HTML Parser.

var map = makeMap(’area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed’);
if( map[tagName]){
// Do something here.
}

Of course we can use RegExp to test it, just like many others did.

var reg = /^(area|base|basefont|br|col|frame|hr|img|input|isindex|link|meta|param|embed)$/i;
var tagName = ‘BR’;
if( reg.test(tagName)){
// Do something…
}

and maybe you can find more tricks that solve the same problem with low cost, but below is the most interesting one that caught my attention.

if ( tagName != “BUTTON” | “B” | “A” ){
// Do something…
}

Wait, this seems really strange to me and seems not to perform as what I was expecting.
However, since I found this code snippets from MSDN, there must be something magic which makes this working.

js code snippets

Unfortunately, this is simply not working though I almost thought I found a new JS pattern from MSDN and was very excited about it for just about 10 seconds.

It’s fun to learn JS from microsoft.

JavaScript

Comments (4)

Permalink

How to display some HTMLs only when JavaScript is enabled?

innerHTML rules!
http://www.hedgerwow.com/360/dhtml/html-yesjs.html

JavaScript
XHTML

Comments (7)

Permalink

A JavaScript Bug of SpiderMonkey on Firefox

Hopefully, we’re safe from this kind of problems..
http://www.hedgerwow.com/360/bugs/js-spider-monkey-bug.html

JavaScript
Firefox Only

Comments (2)

Permalink

Stable Array.sort

I’d think that stable sorting does matter for most sortable UI, and it’s better to let JS to do it natively since we use JS a lot to make UI sortable.
http://www.hedgerwow.com/360/dhtml/js_array_stable_sort.html

JavaScript

Comments (0)

Permalink

Long Word breaker

for really long words in HTML, there’s a way to break it.
http://www.hedgerwow.com/360/dhtml/css-word-break.html

JavaScript
CSS
layout
FancyStyle

Comments (2)

Permalink

Finally, the alternative fix for IE6’s memory leak is available

Some languages suggest that using try….finally block statement may help to prevent the memory leak, and this rule apply to JScript in IE, too.

http://www.hedgerwow.com/360/dhtml/ie6_memory_leak_fix/

JavaScript
IE only
memory leak

Comments (0)

Permalink

JavaScript, the unnecessary part : About Label

My answer which explain why people like to use JavaScript label for inline script unconsciously.
http://www.hedgerwow.com/360/dhtml/js_label/

JavaScript

Comments (1)

Permalink

Simple “Class” Instantiation, the alternative solution.

My two cents for this little JavaScript trick.
http://www.hedgerwow.com/360/dhtml/js-simple-instantiation.html

JavaScript
ObjectOriented

Comments (0)

Permalink