Solved

Javascript: want Refresh every 15 minutes to submit function

Posted on 2009-07-09
4
425 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Handling case and special names in javascript 3 51
Problem in javascript 17 57
Embedd an image or live dashboard into Slack 1 54
Sending HTML Formatted Email from ASP.NET 2 55
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.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

732 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