Jump to content

IE : Out of Memory


Largozol

Recommended Posts

Hello all!I was trying to create a javascript clock,when i got this alert by Internet Explorer - "Out Of Memory at : line 9" ! What does it mean?thats the code i used :

<html><head><script>function clock() {var time= new Date()var hours=time.getHours()var min=time.getMinutes()var sec=time.getSeconds()document.gos.dao.value=hours + ":" + min + ":" + secsetTimeout(clock() ,1000)}</script><body onLoad="clock()"><form name="gos"><input type="text" name="dao" ></form></body></head></html>

Link to comment
Share on other sites

1. The body cannot be in the head of a document, they are both separate2. You were calling the clock function from within itself using settimeout, i think that's where the error was coming from, try calling it from the body using a setinterval

<html><head>  <title></title><script language="JavaScript" type="text/javascript">function clock() {        var now = new Date();        var hh = now.getHours();        var mm = now.getMinutes();        var ss = now.getSeconds();        if (mm<10) {                document.clock.time.value=hh+":0"+mm;        } else  {                document.clock.time.value=hh+":"+mm;        }        if (ss<10){                document.clock.time.value=document.clock.time.value+":0"+ss;        } else {                document.clock.time.value=document.clock.time.value+":"+ss;        }}</script></head><body onload="window.setInterval('clock();',1000);">  <form name="clock" id="clock">    <input type="text" name="time" />  </form></body></html>

Link to comment
Share on other sites

Hey scott,thank you, i fixed the <body> section , but the problem remains.I was following this tutorial and it uses the settimeout() within the function,and it seems to work. I had never seen a message like "Out of memory" before.

Use the code i gave u it works fine...
Link to comment
Share on other sites

its not that i need а clock,i just want to know what went wrong in this case.Does anybody else know what тhat error means?

He did tell you...you were calling the clock function from within the clock function this creates an endless cycle which eats away at the memoery...look are his solution to understand where you went wrong
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...