JavaScript - An open source scripting language, it allows the creation of dynamic web page content.  Home Web Programming JavaScript Last Modified, Loading Time, Preload your Images

Last Modified, Loading Time, Preload your Images


Last Modified, Loading Time, Preload your ImagesLast Modified

This javascript code will allow you to display the date of the page's last modification:

<script language="javascript">

date=document.lastModified
day=date.charAt(3)+date.charAt(4)
month=date.charAt(0)+date.charAt(1)
year=date.charAt(6)+date.charAt(7)+date.charAt(8)+date.charAt(9)
document.write("Last modification made on : "+day+"/"+month+"/"+year)

</script>

Preload your Images

This script will allow you to preload your images and let your navigator restore them fast when your page opens, in this example we will preload the image splash.jpg that exists in the same directoruy as your page:

<script language="javascript">
if (navigator.appVersion.substring(0,1)>=3)
{
i1=new Image;
i1.src='splash.jpg';
}
</script>

Loading Time

In the following tutorial we will learn how to display the page's loading time in the status bar of your navigator, you have to insert the following code  between the <head> and </head> tags:

<script language="javascript">

NavName = navigator.appName.substring(0,3);
NavVersion = navigator.appVersion.substring(0,1);
if (NavName != "Mic" || NavVersion>=4)
{
start = new Date;
start = start .getTime();
}
function loadtime()
{
if (NavName != "Mic" || NavVersion>=4)
{
end = new Date;
end = end.getTime();
seconds = (end-start )/1000;
if (seconds>1)
{
window.status='Page loaded in ' + seconds + ' seconds.';
}
else
{
window.status='Page loaded in ' + seconds + ' second.';
}
}
}

</script>

The following code must be inserted inside the <body> tag this way :

<body onLoad="loadtime()">



Author's URL: Kyscorp.com
JavaScript - An open source scripting language, it allows the creation of dynamic web page content. More JavaScript Tutorials: Featured Materials | Fresh Materials | More JavaScript Tutorials at LearnPHP.org

Reader's comments
comments NR March 27, 2010 says:
Thanks. with Chrome, several last modified scripts are "iffy". Could you direct me to the script for a "page last (Changed content). And I am unable to find a reasonable and helpful group/alt.something that takes a little time and points one to the answer or the right "direction". Do you know of any? Thanks
NR
Washington DC

Reply
Add comments to "Last Modified, Loading Time, Preload your Images"

Captcha