Solved

Random META Refresh 30-90seconds

Posted on 2001-08-19
6
569 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Do you want to insert HTML5 video into your site? This is the tutorial how to do so. What are the main advantages of HTML5 video? 1) Have good compression, good image quality, and low decode processor use. 2) It is royalty-free 3) It is easi…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

708 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