Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript clock stops when another countdown timer start
    text
    copied!<p>in my page i have a main clock javascript timer who stops when i try to load another page with countdown timer.Specific my clock timer stops when i call this code <code>&lt;body onload="setCountDown();"&gt;</code> </p> <p>my head is</p> <pre><code>&lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;link rel="stylesheet" href="css/screen.css"&gt; &lt;!-- &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"&gt;&lt;/script&gt; --&gt; &lt;script&gt; function myfunction(val) { //document.write(val); var selection = val; document.getElementById("searchSelection").innerHTML = 'Type ' + selection; } &lt;/script&gt; &lt;?php if(@$_GET["action"]=="getTime"){ $time1 = Time(); $date1 = date("h:i:s A",$time1); echo $date1; // time output for ajax request die(); } ?&gt; &lt;script type="text/javascript"&gt; window.onload = startInterval; function startInterval() { intervalClock = setInterval("startTime();",0000); } function startTime() { AX = new ajaxObject("?action=getTime", showTime) AX.update(); // start Ajax Request } // CallBack function showTime( data ){ document.getElementById('clock').innerHTML = data; } &lt;/script&gt; &lt;script type="text/javascript"&gt; // Ajax Object - Constructor function ajaxObject(url, callbackFunction) { var that=this; this.updating = false; this.abort = function() { if (that.updating) { that.updating=false; that.AJAX.abort(); that.AJAX=null; } }; this.update = function(passData,postMethod) { if (that.updating) { return false; } that.AJAX = null; if (window.XMLHttpRequest) { that.AJAX=new XMLHttpRequest(); }else{ that.AJAX=new ActiveXObject("Microsoft.XMLHTTP"); } if (that.AJAX==null) { return false; }else{ that.AJAX.onreadystatechange = function() { if (that.AJAX.readyState==4) { that.updating=false; that.callback( that.AJAX.responseText, that.AJAX.status, that.AJAX.responseXML, that.AJAX.getAllResponseHeaders() ); that.AJAX=null; } }; that.updating = new Date(); if (/post/i.test(postMethod)) { var uri=urlCall+(/\?/i.test(urlCall)?'&amp;':'?')+'timestamp='+that.updating.getTime(); that.AJAX.open("POST", uri, true); that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); that.AJAX.setRequestHeader("Content-Length", passData.length); that.AJAX.send(passData); }else{ var uri=urlCall+(/\?/i.test(urlCall)?'&amp;':'?')+passData+'&amp;timestamp='+(that.updating.getTime()); that.AJAX.open("GET", uri, true); that.AJAX.send(null); } return true; } }; var urlCall = url; this.callback = callbackFunction || function (){}; } &lt;/script&gt; &lt;script type="text/javascript"&gt; var years = &lt;?php echo $time_remaing[0]; ?&gt; var months = &lt;?php echo $time_remaing[1]; ?&gt; var days = &lt;?php echo $time_remaing[2]; ?&gt; var hours = &lt;?php echo $time_remaing[3]; ?&gt; var minutes = &lt;?php echo $time_remaing[4]; ?&gt; var seconds = &lt;?php echo $time_remaing[5]; ?&gt; function setCountDown () { if ( years == '0' &amp;&amp; months == '0' &amp;&amp; days == '0' &amp;&amp; hours == '0' &amp;&amp; minutes == '0' &amp;&amp; seconds == '0') { document.getElementById("remain").innerHTML = "Auction has expire"; clearTimeout(SD); return; } else { seconds--; if (seconds &lt; 0){ minutes--; seconds = 59 } if (minutes &lt; 0){ hours--; minutes = 59 } if (hours &lt; 0){ days--; hours = 23 } document.getElementById("remain").innerHTML = days+" days, "+hours+" hours, "+minutes+" minutes, "+seconds+" seconds"; SD=window.setTimeout( "setCountDown()", 1000 ); if ( years == '00' &amp;&amp; months == '00' &amp;&amp; days == '00' &amp;&amp; hours == '00' &amp;&amp; minutes == '00' &amp;&amp; seconds == '00') { seconds = "00"; clearTimeout(SD); window.clearTimeout(SD); //window.alert("Time is up. Press OK to continue."); // change timeout message as required window.location = "http://www.yourpage.com" // Add your redirect url } } } &lt;/script&gt; &lt;/head&gt; </code></pre> <p>the body of my page</p> <pre><code>&lt;?php include 'core/init.php'; protect_page(); $time_remaing = countdown(12,9,2013,02,00,00); ?&gt; &lt;!doctype html&gt; &lt;html&gt; &lt;?php include 'includes/head.php'; ?&gt; &lt;body&gt; &lt;?php include 'includes/header.php'; ?&gt; &lt;div id="container"&gt; &lt;?php include 'includes/aside.php'; ?&gt; &lt;h1&gt;Auction for product..&lt;/h1&gt; &lt;p&gt;product discription&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a picture here&lt;/p&gt; &lt;p&gt; &lt;div class="box" style="width:600px;"&gt; &lt;body onload="setCountDown();"&gt; &lt;div id="remain"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/p&gt; &lt;h2&gt;Give your offer please&lt;/h2&gt; &lt;p&gt; &lt;form action="" method="post"&gt; &lt;ul&gt; &lt;li&gt;Set a price:&lt;br/&gt; &lt;input type="text" name="time_start"/&gt; &lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt; &lt;input type="submit" value="Submit Offer" name="insert_auction"&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/form&gt; &lt;/p&gt; &lt;?php include 'includes/overall/overallfooter.php'; ?&gt; </code></pre> <p>I try some solutions but still don't working..</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload