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
Solved

Random META Refresh 30-90seconds

Posted on 2001-08-19
6
586 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
div to fit another div 8 28
Can't get container centered 4 24
Html value of radio 14 27
How to create a table with buttons 3 21
Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
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.
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…
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…

808 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