Solved

Random META Refresh 30-90seconds

Posted on 2001-08-19
6
575 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

948 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

18 Experts available now in Live!

Get 1:1 Help Now