IT翻訳 Nobuyuki の仕事部屋

ボランティアでソフトウエアーローカライズのために翻訳をしている。

JavaScript-DOM Prototypes in Mozilla 草稿化 4

2006-03-16 23:58:26 | InDraft


原文青色表示
訳文黒色表示
注記/訂正: 赤色表示

This would make every image in this document have a callable foo property (i.e. a foo() method).
このコードを使ったドキュメント中のすべてのイメージは呼び出し可能な foo プロパティ (例 foo() method) を備えます。

Alternatively, and this is actually the standard way of doing this (see the ECMAScript specification), one can access and modify the prototype of an HTMLImageElement through the prototype property of the constructor function:
HTMLImageElement.prototype.foo = bar;

別の方法では、実のところこれをするための標準的方法ですが(ECMAScript 仕様を参照してください)、コンストラクタ関数のプロトタイププロパティを通して HTMLImageElement のプロトタイプにアクセスし変更できます:
HTMLImageElement.prototype.foo = bar;


And a third way (also per the ECMAScript specification) through which one can access the prototype of an object is through the constructor property's prorotype property:
document.images[0].constructor.prototype.foo = bar;

3番めの方法としては(これも ECMAScript 仕様によるのですが)、コンストラクタのプロパティのプロトタイププロパティを通してオブジェクトのプロトタイプへアクセスことができます:
document.images[0].constructor.prototype.foo = bar;


Note though, the above does not yet work in Mozilla.
しかしこの方法は まだ Mozilla で機能しません。