Skip to main content
Email Password   helpLost your password?

Introduction

Displaying Server Date and Time continuously in Web Applications is a big deal. It is difficult in java script to calculate the date and time and may consume memory in IE.

I have done it two ways one using Web Services and other using Iframe.

At last satisfied with the Iframe implementation.

I used some DHTML and Javascript to display the Server Date and Time along with Server side code.

The advantage of this script is the page is displayed only when the page loads other wise it will not display any thing and there is no flickering in page.

ServerDateTimeTest.htm
===========================
<body>
<!--<span id="clock" nowrap></span>-->
<iframe name="FRAME1" src='serverDateTime.aspx' width="350" height="20" frameborder="0" style="visibility:hidden" >
</iframe>
</body>

ServerDateTime.aspx
===========================

<script language="javascript">
function PageInit()
{
VisibleIframe(true)
setInterval("ReloadPage()", 1000 * 60);
}
function ReloadPage()
{
VisibleIframe(false)
location.reload();
}
function VisibleIframe(Visible)
{
var strdisplay = "hidden";
if(Visible)
{
strdisplay = "visible";
}
if(window.parent != null && window.parent.document.getElementById("Frame1") != null)
{
window.parent.document.getElementById("Frame1").style.visibility = strdisplay;
}
}
</script>
</HEAD>
<body onload="PageInit()" leftmargin="0" topmargin="0" bottommargin="0" style="background-color:#c67529">

For Performance improvement Cache the page for one minute.

<script language=javascript> function PageInit() { VisibleIframe(true) setInterval("ReloadPage()", 1000 * 60); } function ReloadPage() { VisibleIframe(false) location.reload(); } function VisibleIframe(Visible) { var strdisplay = "hidden"; if(Visible) { strdisplay = "visible"; } if(window.parent != null && window.parent.document.getElementById("Frame1") != null) { window.parent.document.getElementById("Frame1").style.visibility = strdisplay; } } </script> <script language=javascript> function PageInit() { VisibleIframe(true) setInterval("ReloadPage()", 1000 * 60); } function ReloadPage() { VisibleIframe(false) location.reload(); } function VisibleIframe(Visible) { var strdisplay = "hidden"; if(Visible) { strdisplay = "visible"; } if(window.parent != null && window.parent.document.getElementById("Frame1") != null) { window.parent.document.getElementById("Frame1").style.visibility = strdisplay; } } </script>
You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralI think not Pin
Chris Maunder
1:33 27 Jan '08  


Last Updated 12 May 2005 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009