Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Sunday, July 11, 2010

eMule one-click AddOn, a new project is created

It's a firefox add-on that I made recently, just because I'm tried to copy/paste a ed2k link from a window to another windows if you have used eMule web interface to remotely control your eMule client.

Project home:
http://code.google.com/p/emule-oneclick-add-on/

Mozilla Add-On install:
https://addons.mozilla.org/en-US/firefox/addon/195536/

Monday, January 25, 2010

关于对DOM Level 1和2的理解。

参考:
https://developer.mozilla.org/En/DOM_Levels

根据自己的理解总结一下DOM Levels的实现。

DOM Level 1:
实现了文档结构化,就是《a href="xx" target=""》这样的tag以及attribute的定义。
http://www.w3.org/TR/DOM-Level-1/

DOM Level 2:
1.实现了命名空间。
2.实现动态更新以及访问(动态更新后可以看到更新结果)。addChild, removeChild
3.事件,比如addEventListener,来实现响应各种事件,比如EventTarget, MouseEvent(但不包括键盘事件,奇怪,文档上是这么说的)
4.支持CSS的访问了。 比如div.style.display='none';还有一些CSS相关的方法。
5.实现Traversal,比如NodeIterator(我是没用过)。还有Range,这个在online editor里常见,就是TextRange之类的实现。这块不熟,还是看要w3c的详细文档吧:http://www.w3.org/TR/DOM-Level-2-Traversal-Range/

总之现在主流的浏览器基本实现了Level2 小量实现了Level3。

Friday, January 22, 2010

A little example to figure out Javascript scope

function f1() { var a=1; f2(); }
function f2() { alert(a); }
f1();


function f1() { 
var a=2;
function f2() {
alert(a);
}
f2();
}
f1();


Try it.

Monday, May 4, 2009

two useful String extend functions.


String.prototype.trim = function() {
return this.replace( /^\s*|\s*$/g, "" );
}

String.prototype.addslashes = function () {
return this.replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
}

Thursday, April 2, 2009

a way to Limit textarea max length.

a way to Limit textarea max length.


function keyup_info_description( inLengthMaximum ) {
if ( inLengthMaximum < document.getElementById('info_description').value.length )
document.getElementById('info_description').value = document.getElementById('info_description').value.slice( 0, inLengthMaximum );
}