I have a web page using the milonic menu, but this page also dynamically updates some contents of a <div> roughly every minute. The problem is that after some time the browser would crash (both in vista and in xp).
Removing the call to drawMenus() and the page doesn't crash.
The sample code below is essentially rewriting the contents of a div every 5ms. I first render the menus by calling drawMenus() and then begin my updates. If I didn't call the drawMenus() the page would continue to update normally for a long period. With the call to drawMenus() the page would crash after about 3 minutes
You can replace the img1.jpg with any image. I also ran this on a tomcat server. Any help/feedback appreciated.
Thanks
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Milonic test</TITLE>
<script type="text/javascript" src="milonic_src.js"></script>
<script type="text/javascript" src="mmenudom.js"></script>
<!-- <script type="text/javascript" src="mmenuns4.js"></script> -->
</HEAD>
<BODY>
<script type="text/javascript">
with(milonic=new menuname("Main Menu")){
alwaysvisible=1;
orientation="horizontal";
style="topMenuStyle";
aI("showmenu=menu1;");
aI("text=menu1;url=/menu1.html;");
aI("text=menu2;url=/menu2.html;");
aI("text=menu3;url=/menu3.html;");
aI("text=menu4;url=/menu4.html;");
}
drawMenus();
</script>
<div>
<br><br><br>
<div id="myDiv">
</div>
</div>
<script type="text/javascript">
//Loops and reinserts the div into the dom.
setInterval(function() {
var rand = Math.floor(Math.random()*100);
var html = "";
html += "<div>\n";
html += " <img src='img1.jpg' />\n";
html += " <img src='img1.jpg' />\n";
html += " <span>some random number: " + rand + "</span>\n";
html += "</div>\n";
var dom= document.getElementById('myDiv');
dom.innerHTML = html;
},5);
</script>
</BODY>
</HTML>