Solved

Javascript: want Refresh every 15 minutes to submit function

Posted on 2009-07-09
4
421 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

763 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