Solved

Javascript: want Refresh every 15 minutes to submit function

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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.
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…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now