Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

evaldobarbosa

HTMLFormElement

Recommended Posts

Senhores, gostaria que me ajudassem!Meu problema é, como sempre, relacionado à porcaria do IE, seja em qual versão for...Queria saber se alguém o HTMLFormElement sem apresentar erros no IE. Tem alguém que fez isso e qual versão do IE?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Uma vez, eu tentei prototipar um método aos objetos do tipo HTMLElement e descobri que eles simplesmente não existem no IE.

 

Há uma saída em JScript, mas deixa o processamento da página muito mais lento:

 

<!--
HTMLElement Prototyping in Internet Explorer/Win
Copyright (C) 2005  Jason Davis, http://www.jasonkarldavis.com

This code is licensed under the LGPL:
http://www.gnu.org/licenses/lgpl.html

Usage:

<style type="text/css">
* {
behavior: url("HTMLElement.htc");
}
</style>
<script type="text/javascript">
 HTMLElement.prototype.test = function() {
  alert(this.innerHTML);
 }

 document.getElementsByTagName("body").item(0).test(); // alerts its innerHTML
</script>

-->

<PUBLIC:COMPONENT>
<PUBLIC:DEFAULTS viewLinkContent>
<body></body>
</PUBLIC:COMPONENT>

<script LANGUAGE="JScript">

var constructors = {
 html: "Html", head: "Head", link: "Link", title: "Title", meta: "Meta",
 base: "Base", isindex: "IsIndex", style: "Style", body: "Body",
 form: "Form", select: "Select", optgroup: "OptGroup", option: "Option",
 input: "Input", textarea: "TextArea", button: "Button", label: "Label",
 fieldset: "FieldSet", legend: "Legend", ul: "UList", ol: "OList",
 dl: "DList", dir: "Directory", menu: "Menu", li: "LI", div: "Div",
 p: "Paragraph", h1: "Heading", q: "Quote", pre: "Pre", br: "BR",
 basefont: "BaseFont", font: "Font", hr: "HR", ins: "Mod", a: "Anchor",
 img: "Image", object: "Object", param: "Param", applet: "Applet",
 map: "Map", area: "Area", script: "Script", table: "Table",
 caption: "TableCaption", col: "TableCol", tbody: "TableSection",
 tr: "TableRow", td: "TableCell", frameset: "FrameSet", frame: "Frame",
 iframe: "IFrame"
};
var name = "HTML" + constructors[element.tagName.toLowerCase()] + "Element";
var current;

// Initialize constructors
if (!("HTMLElement" in window)) {
 for (var i in constructors) {
current = "HTML" + constructors[i] + "Element";
window[current] = function() {};
document.body.appendChild(document.createElement("span"));
window[current].prototype = document.body.lastChild;
 }
 window.HTMLElement = function() {};
 document.body.appendChild(document.createElement("span"));
 HTMLElement.prototype = document.body.lastChild;
}

// Force inheritance
for (var i in HTMLElement.prototype) {
 if (!(i in element) && i != "dataFormatAs" && i != "dataSrc" && i != "dataFld")
 element[i] = HTMLElement.prototype[i];
}
for (var j in window[name].prototype) {
 if (!(j in element) && j != "dataFormatAs" && j != "dataSrc" && j != "dataFld")
 element[j] = window[name].prototype[j];
}

// Map expando properties to "inherited" properties
HTMLElement.prototype.attachEvent("onpropertychange", function() {
 if (!(event.propertyName in window[name].prototype)) {
element[event.propertyName] = HTMLElement.prototype[event.propertyName];
 }
});
window[name].prototype.attachEvent("onpropertychange", function() {
 element[event.propertyName] = window[name].prototype[event.propertyName];
});

</SCRIPT>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.