Solved

Javascript: want Refresh every 15 minutes to submit function

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
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 basics of jQuery including how to code hide show and toggles. 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…

910 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

21 Experts available now in Live!

Get 1:1 Help Now