Menu
Hi all
We have put together an unobtrusive implementation of the HTMLElement and sub interfaces for IE 6.0+. The first beta version is out and we would very much like some help testing it.
For those of you who can spare some free time please see [URL=”http://www.jslab.dk/epe.introduction.php”]http://www.jslab.dk/epe.introduction.php
Any help is appreciated.
<i>
</i><!--[if IE]>
<style type="text/css">
*{behavior:url(htmlelement.htc)}
</style>
<![endif]-->
<script type="text/javascript">
if(typeof HTMLElement=="undefined")HTMLElement=new Function();
if(typeof HTMLSelectElement=="undefined")HTMLSelectElement=new Function();
HTMLSelectElement.prototype.c=function(){
alert(this.options[this.options.selectedIndex].text)
};
</script>
</head>
<body>
<select onchange="this.c()"><option>true<option>false</select>
</body>
</html>
<i>
</i><PUBLIC:COMPONENT>
<script type="text/javascript">
//element is set via HTC
for(prop in HTMLElement.prototype)
element[prop]=HTMLElement.prototype[prop];
if(element.tagName=="SELECT")
for(prop in HTMLSelectElement.prototype)
element[prop]=HTMLSelectElement.prototype[prop];
</script>
</PUBLIC:COMPONENT>
<i>
</i><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="eng">
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<title></title>
<script type="text/javascript" src="http://www.jslab.dk/scripts/epe.1.9.4.js"></script>
<script type="text/javascript">
HTMLElement.prototype.getOuterHTML=function(){
return document.createElement("div").appendChild(this.cloneNode(true)).parentNode.innerHTML;
}
</script>
<script type="text/javascript">
img=(true)?document.createElement("img"):new Image();
img.src="http://www.webdeveloper.com/forum/image.php?u=30185&dateline=1128637189";
img.alt="Ultimater's Avatar";
if(img.getOuterHTML)alert(img.getOuterHTML())
else alert("Failed to inherit!");
</script>
</head>
<body>
<script type="text/javascript">
if(window.EPE){//IE
EPE.__R1=document.documentElement.childNodes[1].onload;
document.documentElement.childNodes[1].onload=EPE.init;
}
</script>
</body>
</html>
[CODE]HTMLElement.prototype.getOuterHTML = function() {
return document.createElement("div").appendChild(this.cloneNode(true)).parentNode.innerHTML;
}[/CODE]
[CODE]HTMLElement.prototype.getOuterHTML = function() {
return 'Inherit succeded';
}[/CODE]
<i>
</i><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="eng">
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<!--<script type="text/javascript" src="http://www.jslab.dk/scripts/epe.1.9.4.js"></script>-->
<script type="text/javascript">
onerror=function(){
alert(Array.apply(null,arguments).join("n"))
}
if(typeof HTMLElement=="undefined")HTMLElement=new Function();
HTMLElement.prototype.getOuterHTML=function(){
return document.createElement("div").appendChild(this.cloneNode(true)).parentNode.innerHTML;
}
</script>
<title></title>
</head>
<body>
<script type="text/javascript">
img=(true)?document.createElement("img"):new Image();
img.src="http://www.webdeveloper.com/forum/image.php?u=30185&dateline=1128637189";
img.alt="Ultimater's Avatar";
alert(HTMLElement.prototype.getOuterHTML.apply(img))
</script>
</body>
</html>
<i>
</i><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="eng">
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<title></title>
<script type="text/javascript" src="http://www.jslab.dk/scripts/epe.1.9.5.js"></script>
<script type="text/javascript">
HTMLElement.prototype.getOuterHTML=function(){
return document.createElement("div").appendChild(this.cloneNode(true)).parentNode.innerHTML;
}
HTMLTableRowElement.prototype.insertCells=function(n){
for(var i=0;i<n;i++)
this.insertCell(-1)
return this.getElementsByTagName("td");
}
var tbl=document.createElement("table");
var row=tbl.insertRow(-1);
if(row.insertCells){
var cells=row.insertCells(3);
cells[0].appendChild(document.createTextNode("1"))
cells[1].appendChild(document.createTextNode("2"))
cells[2].appendChild(document.createTextNode("3"))
alert(tbl.getOuterHTML())
}
else alert("Failed to inherit!");
</script>
</head>
<body>
<script type="text/javascript">
if(window.EPE){//IE
EPE.__R1=document.documentElement.childNodes[1].onload;
document.documentElement.childNodes[1].onload=EPE.init;
}
</script>
</body>
</html>
<i>
</i><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="eng">
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<title></title>
<script type="text/javascript" src="http://www.jslab.dk/scripts/epe.1.9.6.beta.js"></script>
<script type="text/javascript">
HTMLElement.prototype.getOuterHTML=function(){
return document.createElement("div").appendChild(this.cloneNode(true)).parentNode.innerHTML;
}
HTMLTableRowElement.prototype.insertCells=function(n){
for(var i=0;i<n;i++)
this.insertCell(-1)
return this.getElementsByTagName("td");
}
Object.prototype.appendChildren=function(){
for(var i=0;i<arguments.length;i++)
this[i].appendChild(arguments[i]);
}
var tbl=document.createElement("table");
with(document)a=[createTextNode("1"),createTextNode("2"),createTextNode("3")];
var cells=tbl.insertRow(-1).insertCells(3);
if(cells.appendChildren){
cells.appendChildren(a[0],a[1],a[2])
alert(tbl.getOuterHTML())
}
else alert("Failed to inherit");
</script>
</head>
<body></body>
</html>
0.1.9 — BETA 5.2