Note that there are some explanatory texts on larger screens.

plurals
  1. POTime and date disappear after reload several times
    primarykey
    data
    text
    <h2>Javascript/jQuery/jQuery Mobile</h2> <p>The codes below work fine but when I reload/F5 several times of this page, the currentDate and currentTime values are disappear. Then when I reload several times again, its work fine. Does anyone know what is the cause and how to solve it? </p> <pre><code> &lt;%@ include file="/common/taglibs.jsp"%&gt; &lt;%@ include file="/common/jquery-mobile-javascript-css.jspf"%&gt; &lt;%@ include file="/common/jquery-mobile-javascript.jspf"%&gt; &lt;!DOCTYPE html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;title&gt;JSP Page&lt;/title&gt; &lt;script type="text/javascript"&gt; &lt;script type="text/javascript"&gt; jQuery.noConflict(); jQuery(document).ready(function() { function DisplayTime(){ if (!document.all &amp;&amp; !document.getElementById) return var timeElement=document.getElementById? document.getElementById("curTime"): document.all.tick2; var CurrentDate=new Date(); var hours=CurrentDate.getHours(); var minutes=CurrentDate.getMinutes(); var seconds=CurrentDate.getSeconds(); var year=CurrentDate.getYear(); if (hours&lt;=9) { hours="0"+hours; } if (minutes&lt;=9) { minutes="0"+minutes; } if (seconds&lt;=9) { seconds="0"+seconds; } if(year &lt; 1000){ year += 1900; } var currentTime=hours+":"+minutes+":"+seconds; var currentDate=dayNames[CurrentDate.getDay()]+' '+monthNames[CurrentDate.getMonth()]+' '+CurrentDate.getDate()+', '+year; document.getElementById('curDate').innerHTML="&lt;font style='font-size:18px;font-weight:bold;'&gt;"+currentDate+" &lt;/b&gt;"; timeElement.innerHTML="&lt;font style='font-size:18px;font-weight:bold;'&gt;"+currentTime+"&lt;/b&gt;"; setTimeout(DisplayTime,1000); } window.onload=DisplayTime; &lt;/script&gt; &lt;/head&gt; </code></pre> <h2>Html</h2> <pre><code> &lt;body&gt; &lt;div id="page" data-role="page"&gt; &lt;div data-role="header" data-theme="b" data-position="fixed"&gt; &lt;p class="ui-li-aside"&gt;&lt;span id=curDate&gt;&lt;/span&gt;&lt;span id=curTime&gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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