sitelink1 | |
---|---|
sitelink2 | |
sitelink3 | |
sitelink4 | http://1 |
extra_vars4 | ko |
extra_vars5 | http://arstechnica.com/civis/viewtopic.php?f=20&t=185317 |
extra_vars6 | sitelink1 |
Question
Object.prototype.removeNodes = function() { var node = this; while (this.lastChild) node.removeChild(this.lastChild); }The purpose of this prototype is to remove all children from an element. It works fine in Gecko, WebKit/KHTML, and Opera. But not IE.
IE does not support prototype extensions of HTML elements.
So you have to fake it instead with something like...
http://www.geekdaily.net/2007/06/18/javascript-htmlelement-in-ie/
or
http://delete.me.uk/2004/09/ieproto.html
or maybe
http://www.browserland.org/scripts/htmlelement/
결론은
Element = function () {};
Element.prototype.getAttribute = function (attribute) {
if (attribute == "class") attribute = "className";
if (attribute == "for") attribute = "htmlFor";
return this[attribute];
}
Element.prototype.setAttribute = function (attribute, value) {
if (attribute == "class") attribute = "className";
if (attribute == "for") attribute = "htmlFor";
this[attribute] = value;
}
------------------------------------------------------------------------------------
createElement 재정의 방법1
var __IEcreateElement = document.createElement;
document.createElement = function (tagName) {
var element = __IEcreateElement(tagName);
var interface = new Element;
for (method in interface)
element[method] = interface[method];
return element;
}
------------------------------------------------------------------------------------
createElement 재정의 방법2
document.createElement = (function(fn){
return function(tagName){
var elem = fn.call(document, tagName);
elem.$ = function(){
alert(arguments[0])
}
return elem;
};
})(document.createElement);
------------------------------------------------------------------------------------
createElement 재정의 방법3 (추천)
document._createElement = document.createElement;
document.createElement = function(tag)
{
var el=document._createElement(tag);
el.methodYouWantToAdd = function(args) {
//do stuff with "this"
return this;
}
return el;
}
------------------------------------------------------------------------------------
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
137 | 라이노 (Rhino) 관련 링크 모음 | 황제낙엽 | 2008.07.21 | 74 |
136 | |= 비트 OR 대입 연산자 (복합대입연산자) | 황제낙엽 | 2017.03.15 | 73 |
135 | JScript Memory Leaks | 황제낙엽 | 2011.11.28 | 69 |
134 | HTTP Content-Type 정리 | 황제낙엽 | 2013.09.30 | 68 |
133 | 자바스크립트 숫자형 체크 함수 (isFinite() 함수 와 isNaN() 함수) | 황제낙엽 | 2011.12.13 | 67 |
132 | innerHTML | 황제낙엽 | 2005.12.19 | 67 |
131 | 아이디 생성 조건 검사 자바스크립트 모듈 | 황제낙엽 | 2004.11.18 | 67 |
130 | SpiderMonkey와 Tamarin | 황제낙엽 | 2008.07.14 | 66 |
129 | 상속과 Super 로의 접근 | 황제낙엽 | 2012.09.18 | 64 |
128 | 콜백지옥과 비동기제어 | 황제낙엽 | 2021.02.18 | 63 |
127 | XMLHttpRequest.setRequestHeader | 황제낙엽 | 2013.09.30 | 62 |
126 | 소숫점을 포함한 반올림 | 황제낙엽 | 2008.12.11 | 62 |
125 | Understanding delete | 황제낙엽 | 2011.11.28 | 61 |
124 | Iframe 내의 페이지 접근방법 | 황제낙엽 | 2009.11.12 | 59 |
123 | XMLHttpRequest 제대로 활용하기 | 황제낙엽 | 2017.08.01 | 58 |
122 | Javascript 내장객체 Array (배열) | 황제낙엽 | 2008.10.13 | 57 |
121 | charcode 32와 160 차이 (javascript char 160 to 32) | 황제낙엽 | 2019.05.11 | 55 |
120 | 체인 생성자(생성자 체인), 프로토타입 체인 그리고 생성자 재지정 | 황제낙엽 | 2009.08.12 | 55 |
119 | 다양한 WYSIWYG 에디터 | 황제낙엽 | 2011.11.13 | 54 |
118 | State of ECMAScript 4 ('07 12) | 황제낙엽 | 2008.07.14 | 54 |