Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setInterval Overhead

 
Nilabhra Banerjee
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

I have written a script in the body which will write a cookie with very short expiry at certain interval. I have used setInterval to achieve this. Now, I would like to know

a) whether it carries any significant overhead in terms of memory and processing time.


<script language="JavaScript">
writeCookie();
timerId = setInterval("writeCookie()", 3000);
</script>

b) I am creating the cookie with expiry as current-time + 4 second. I am recreating the cookie with script, as you can see, every 3 seconds.
My page takes 2 seconds to load (lots of data). If I decrease the expiry to 2 seconds and interval to 1 seconds, will the next interval sequence fire before the page loads?


Thanks and regards
Nilabhra Banerjee
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I ask you what is the purpose of doing this? Sounds like you are recreating a basic session cookie which expires when the browser closes.

Eric
[ July 11, 2006: Message edited by: Eric Pascarello ]
 
Nilabhra Banerjee
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are right. And I could have also wrote it down in onload or onunload of the body. But there are restrictions on doing it.

Scenario is like this, my welccome page needs to identify whether any page from the application is open or not. if open, that already open page needs to be popped up and focused. To identify this I need a session cookie, but unfortunately a session cookie for a browser window is not available another browser window. So I have to save it.

Neil
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you opening up another window that is not reading the session cookie? I am assuming a pop up window....

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic