<html>
<head>
<title>JScript Function Spending</title>
<meta name="author" content="birdshome@博客园" />
</head>
<body onunload="ReleaseElements()">
<button id="NamedMethod" onclick="GenerateObjects(this)">
Append Normal Elements</button>
<button id="AnonymousMethod" onclick="GenerateObjects(this)">
Append Inline Elements</button>
<div id="container">
</div>
<script language="Javascript">
function GenerateObjects(elmt)
{
var room = document.getElementById('container');
for ( var i=0 ; i < 1000 ; ++i )
{
var obj = new TestObject('__Object__' + i);
room.appendChild(obj.Render(document, elmt.id));
}
}
function TestObject(name)
{
this.m_Name = name;
this.m_Description = '';
this.m_Element = null;
this.toString = function()
{
return '[class TestObject]';
}
}
function TestObject.prototype.Render(doc, id)
{
var span = doc.createElement('SPAN');
span.Object = this;
this.m_Element = span;
if ( id == "NamedMethod" )
{
span.onclick = asdf;
}
else
{
span.onclick = function()
{
var asdf01 = ['a', 's', 'd', 'f'];
var asdf02 = ['a', 's', 'd', 'f'];
var asdf03 = ['a', 's', 'd', 'f'];
var asdf04 = ['a', 's', 'd', 'f'];
var asdf05 = ['a', 's', 'd', 'f'];
var asdf06 = ['a', 's', 'd', 'f'];
var asdf07 = ['a', 's', 'd', 'f'];
var asdf08 = ['a', 's', 'd', 'f'];
var asdf09 = ['a', 's', 'd', 'f'];
var asdf10 = ['a', 's', 'd', 'f'];
var asdf11 = ['a', 's', 'd', 'f'];
var asdf12 = ['a', 's', 'd', 'f'];
};
}
span.Name = this.m_Description;
span.innerText = this.m_Name;
span.style.display = 'block';
return span;
}
function asdf()
{
var asdf01 = ['a', 's', 'd', 'f'];
var asdf02 = ['a', 's', 'd', 'f'];
var asdf03 = ['a', 's', 'd', 'f'];
var asdf04 = ['a', 's', 'd', 'f'];
var asdf05 = ['a', 's', 'd', 'f'];
var asdf06 = ['a', 's', 'd', 'f'];
var asdf07 = ['a', 's', 'd', 'f'];
var asdf08 = ['a', 's', 'd', 'f'];
var asdf09 = ['a', 's', 'd', 'f'];
var asdf10 = ['a', 's', 'd', 'f'];
var asdf11 = ['a', 's', 'd', 'f'];
var asdf12 = ['a', 's', 'd', 'f'];
}
</script>
<script language="javascript">
function ReleaseElements()
{
var room = document.getElementById('container');
var spans = room.all.tags('SPAN');
for ( var i=0 ; i < spans.length ; ++i )
{
spans[i].Object = '';
}
}
</script>
</body>
</html>
您可能感兴趣的文章: