Perform
is in the CSDN forum to see a problem, usually I did not notice, or said no such use. Look at the code:
The following is a reference fragment:
<body id= "www.never-online.net" >
<script>
var foo = function () {
var $ = function () {return document.getElementById (Arguments[0]);}
$ ("D2"). InnerHTML = $ ("D1"). InnerHTML;
}
]]>
</script>
<button >foo () </button>
<div id= "D1" style= "color:red" >
<input value= ' Blog.never-online '/>
<input value= ""/>
</div>
<div id= "D2" >
</div>
</body>
It's not the expected outcome, is it? including in opera under the implementation of the same as Firefox under the same, you can try to run under opera will understand.
What if we could get the results we expected? I tried to get all the innerHTML in Mozilla under the __definegetter__ method, but it gave me some hints. For example: The following is a quote fragment:
<script type= "text/javascript" >
function Elementdetail (e) {
if (!e.attributes) return "";
var attrs = e.attributes; var str = "<" + e.tagname;
for (var i=0; i<attrs.length; i++) {
STR + + ' +attrs[i].name+ ' = ' +attrs[i].value+ ' ';
}; STR + + ">";
return str;
}
function foo () {
var a = document.getElementById ("D1");
var str = "";
for (var i=0; i<a.childnodes.length; i++) {
var chld = a.childnodes[i];
str = Elementdetail (CHLD);
}
alert (str);
}
</script>
<button >foo () </button>
<div id= "D1" style= "color:red" >
<input value= ' Blog.never-online '/>
<input value= "script by Never-online"/>
</div>
<div id= "D2" >
</div>
Although the above code does not achieve the intended purpose, but is to know that must get the value of attribute, so I try to use the following method to do.
<script type= "Text/javascript" >
var $ = function (ID) {return document.getElementById (ID);}
function foo () {
$ ("D2"). InnerHTML = $ ("D1"). InnerHTML;
}
</script>
<button >foo () </button>
<div id= "D1" >
<input value= ' blog.never-online ' onkeyup= ' This.setattribute (' value ', this.value) '/>
<input value= "script by Never-online"/>
</div>
<div id= "D2" ></div>
This method is successful, it can be explained that under the Mozilla innerHTML by traversing the elements of all nodes of the tagname and attrubutes to get its innerhtml. Therefore, the innerHTML in our first example does not get the changed value.
At the same time, opera can also be used under this trick. It is also proved that the innerHTML in opera also obtains its innerhtml by traversing the tagname of all nodes of the element and attrubutes.
Is this the standard in the consortium? There is no time to check the information of the world's data, so it is not the coincidence of opera and Mozilla, or IE below to make developers comfortable design.