Solved

Random META Refresh 30-90seconds

Posted on 2001-08-19
6
582 Views
Last Modified: 2008-01-09
Is there any way to create a random interval in the META refresh tag?
I would like the same page on my own server to RANDOMLY refresh every 30 to 90 seconds.

0
Comment
Question by:boopsie
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:a.marsh
ID: 6405205
As far as I know it cannot be done with just HTML. There are two ways I can think of:

1 - Use server side scripting to generate the META tag - let us know what you have available and then we can put a solution together for you.

2 - Use javascript:

<html>
<head>
<script language="javascript">
<!--

refreshString = "window.location.reload();";
randVal = (Math.round(Math.random()*(10-5)))+5;;

window.setTimeout(refreshString, randVal * 1000);

//-->
</script>
</head>
<body>
hello!
</body>
</html>


:o)

Ant
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6405208
Whoops - slight mistake change:

randVal = (Math.round(Math.random()*(10-5)))+5;;

to:

randVal = (Math.round(Math.random()*(90-30)))+30;



I just used smaller numbers while testing it. :o)

Ant
0
 
LVL 1

Accepted Solution

by:
james_beilby earned 200 total points
ID: 6405691
<html>
<head>
<script language="javascript">
<!--
document.write("<meta http-equiv='refresh' content='"+(Math.round(Math.random()*60)+30)+"'>");
//-->
</script>
</head>
<body>
</body>
</html>

This dynamically writes a refresh META tag with the random seconds value. Operationally, it won't be any different from Ant's answer, but you asked to use <meta> tags so... :-)
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 15

Expert Comment

by:a.marsh
ID: 6405698
I was thinking of that James, but (I might be getting confused with something else) I wasn't convinced it would work....especially in different browsers.

Ant
0
 
LVL 1

Expert Comment

by:james_beilby
ID: 6405714
Well it works in Internet Explorer and Netscape which is good enough for me - document.write() is usually pretty reliable when loading the page. But if you're going to use JavaScript at all, you might as well use the window.setTimeout() approach.
0
 

Author Comment

by:boopsie
ID: 6411552
Thank you James, it works perfect!
I've tacked on an extra 100 for a job well done.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: blockā€¦
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

803 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