Solved

Random META Refresh 30-90seconds

Posted on 2001-08-19
6
602 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hide file extensions in Notepad++ tabs 2 81
How to calculate height of a text using jquery 3 56
title attribute 5 33
form isn't working is it missing a document 21 64
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

732 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