Solved

Javascript: want Refresh every 15 minutes to submit function

Posted on 2009-07-09
4
418 Views
Last Modified: 2013-11-19
Hi,
I want every 15 minutes to have the Javascript Refresh to submit a JavaScript function in my page.

How do I do this? I forget the syntax for the refresh and don't know how to have it submit a function.

Thank you,
Bill
0
Comment
Question by:bcarlis
4 Comments
 
LVL 16

Assisted Solution

by:alain34
alain34 earned 150 total points
ID: 24813356
Hello bcarlis,

You can use the following code



<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
      setTimeout("location.reload(true);",timeoutPeriod);
}
//   -->
</script>


This page will refresh every 5 seconds. This is because we're using the 'onload' event to call our function. We are passing in the value '5000', which equals 5 seconds.




Regards,

alain34
0
 
LVL 19

Assisted Solution

by:erikTsomik
erikTsomik earned 50 total points
ID: 24813430
simply add meta tag inside the <head tag
<HEAD>
<META HTTP-EQUIV=REFRESH CONTENT=900>
</HEAD>

CONTENT= means that the page  will be refreshed in number specified
0
 
LVL 2

Author Comment

by:bcarlis
ID: 24814454
Hi,
Thanks for the quick responses!

So the onload calls timedRefresh(lets say 45min)
so if the screen is sitting idle for 45min it will refresh...

that's not what I want. I realize that I maybe shouldn't of used the word "refresh"

What I want is if the screen is sitting idle for 45min, someone is looking things up, entering information into t it will submit my javascript function which will save the data and the screen will be directed to another page.







 



0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 300 total points
ID: 25023731
Something like



<html>
<head>
<script type="text/javascript">
var mins = 45;
var timeout = mins*60*60*1000;
function submitIt() {
  document.forms[0].submit()
}
var tId="";
function timeIt() {
  clearTimeout(tId);
  setTimeout('submitIt()',timeout)
}
window.onmousemove=window.onload=function() {
  timeIt();
}
</head>
<body>
<form action="saveStuff">
<textarea name="stuff"></textarea>
<input type="submit" value="save">
</form>
</body>
</html>

Open in new window

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question