KonquerorとHTMLElement Prototyping
IEやSafari2シリーズに続いてKonquerorでもHTMLElement Prototypingする為のエントリ。
方法その1
3.5.4ではHTMLElementが直球であるのでそれを利用する。いつくらいからHTMLElementがあるかは調べられませんでした。秋口に4系が出ると思うの4系でも利用できるといいな。
<html> <head> <script> alert(HTMLElement in window); // true HTMLElement.prototype.foo = function(){ alert("foo"); }; window.onload = function(){ document.getElementById("foo").foo(); }; </script> <body> <div id="foo">foo</div> </body> </html>
方法その2
document.createElement("html").constructorを辿る方法。
vra Temp = document.createElement("html").constructor; HTMLElement = { prototype : Temp.__proto__.__proto__; }; HTMLElement.prototype.bar = function(){ // 何かする。 };
検証した範囲では…
3.5.4しか調べられていませんが…。3.5.4では上記どちらでも利用できました。
ToDo
近いうちに各ブラウザ毎のまとめエントリを書く。