Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using Javascript, make my page load another page in a delayed time limit

Posted on 2009-07-07
7
Medium Priority
?
328 Views
Last Modified: 2012-06-21
I have a script which you can see in the code below.

What I want it to do though is instead of refreshing the current page in 300 seconds, I want it to load the current page in 300 seconds as if it was loading another page.  Refresh just re-submits post variables but simply just loading the same page again could avoid this.

So, how can I make this script load it's own page again within 300 seconds without using the refresh/reload method?
<script language='javascript'>
		function refreshEvery5Min()
		{
			setTimeout('location.reload(true);',300000);
		}
		onload=refreshEvery5Min();
	</script>

Open in new window

0
Comment
Question by:davideo7
[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
  • 2
7 Comments
 
LVL 8

Expert Comment

by:lharrispv
ID: 24795068
The simplest way would be if JS had a isPostback method like in asp.  Unfortuently they don't.  All is not lost though.

Check this thread out.  The accepted solution will tell you how to do a isPostback in JS.
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23182011.html
ok so knowing that.  set your code up to create your variables etc within a if statement.  If it is not postback then do blah.  If it is then don't do blah.  That way when the page posts back you won't have to worrry about redoing the stuff you don't want it to do.
0
 

Author Comment

by:davideo7
ID: 24795101
What if I simply just want it to go to a different url after a certain amount of seconds?
0
 
LVL 8

Expert Comment

by:lharrispv
ID: 24795144
<html>
<head>
<script type="text/javascript">
<!--
function delayer(){
    window.location = "../javascriptredirect.php"
}
//-->
</script>
</head>
<body onLoad="setTimeout('delayer()', 5000)">
<h2>Prepare to be redirected!</h2>
<p>This page is a time delay redirect, please update your bookmarks to our new
location!</p>

</body>
</html>

http://www.tizag.com/javascriptT/javascriptredirect.php
0
Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

 
LVL 19

Accepted Solution

by:
erikTsomik earned 2000 total points
ID: 24795398
try this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Example of shadowed DIV using the outset border property (liquid size)</title>

<script language='javascript'>
                function refreshMe()
               {
document.location.href = "text4.cfm";
}

function pageRefresher()
{
var refreshDone = false;
if (refreshDone == false)
{
window.setTimeout("refreshMe()", 30000);
}
}
       
                        
        </script>

</head>
<body onload="pageRefresher();">


</body>
</html>
0
 
LVL 8

Expert Comment

by:lharrispv
ID: 24795685
ok that is teh second time today someone posted almost exactly the same thign I did and I didn't get any points.. what is up with that?
0
 

Author Comment

by:davideo7
ID: 24795700
Yours was just a copy and paste job from an external site and wasn't very specific and didn't work.  With his he put more time into it and customized the code to exactly what I needed.  I'm sorry.
0
 
LVL 8

Expert Comment

by:lharrispv
ID: 24795764
Actually I did take time... had to google it.. read it over and make sure it was what you needed.  Also gave you a link to it so you could learn oh and cause I do not plagerise... but  as the old adiage says... teach a man to fish feed him for life give a man a fish feed for a day.....

hope you enjoy your one meal.....

0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will learn how to dynamically set the form action using jQuery.
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…

705 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