Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium



Posted on 2007-07-31
Medium Priority
Last Modified: 2008-02-01
I'm using the following script, I need to reload it every 60 secondes.
How should I do this?

<script type='text/javascript'><!--//<![CDATA[
   document.MAX_ct0 ='{clickurl}';

   var m3_u = (location.protocol=='https:'?'https://ads.a7fr.com/www/delivery/ajs.php':'http://ads.a7fr.com/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=3");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if ((typeof(document.MAX_ct0) != 'undefined') && (document.MAX_ct0.substring(0,4) == 'http')) {
       document.write ("&amp;ct0=" + escape(document.MAX_ct0));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'></scr"+"ipt>");
Question by:cabou

Accepted Solution

ravs120499 earned 1000 total points
ID: 19599060
You can use the setTimeout and setInterval functions in a loop. setTimeout is not a blocking call, and hence is not equivalent to the sleep() function in most other languages. You will need to write code to keep the script "occupied doing nothing" until the timeout event is notified. Not ideal, but no other option in Javascript.

Alternatively you can use the Refresh meta to get the browser to reload the page every n seconds. But this will trigger a refresh in the browser and a call to the server.

- Ravs
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 1000 total points
ID: 19599252
Put the script in a piece of html in an iframe and reload the iframe

function reloadIf() {
var tId = "";
<iframe src="ad.html" onLoad="parent.tId=setInterval('parent.reloadIf()',60000)"></iframe>

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…
Suggested Courses

578 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