javaScript function not called from IE8

i work on page there is problem to call the javascript function call…this page is working on all other browser
and even on IE 8 on the othere system but not work on the same system with IE8…here is my code.

<!doctype html>
	<script >
function startTime() {
    var today = new Date();
    var hr = today.getHours();
    var min = today.getMinutes();
    var sec = today.getSeconds();
    ap = (hr < 12) ? "<span>AM</span>" : "<span>PM</span>";
    hr = (hr == 0) ? 12 : hr;
    hr = (hr > 12) ? hr - 12 : hr;
    //Add a zero in front of numbers<10
    hr = checkTime(hr);
    min = checkTime(min);
    sec = checkTime(sec);
    document.getElementById("clock").innerHTML = "<span>" +hr+ "</span>" + "<span>:</span> " + "<span>"+ "</span>"+"<span>"+min+"</span>" + "<span>:</span>" + "<span>"+ sec+"</span>" + "  " + ap;
    var time = setTimeout(function(){ startTime() }, 500);
function checkTime(i) {
    if (i < 10) {
        i = "0" + i;
    return i;
<style type="text/css">
.clockdate-wrapper {
	background-color: #333;
	padding: 0px;
	max-width: 350px;
	width: 100%;
	text-align: center;
	border-radius: 5px;
	margin: 0 auto;
	margin-top: 15%;
#clock {
	font-family: sans-serif;
	font-size: 40px;
	text-shadow: 0px 0px 1px #fff;
	width: 300px;
	font-weight: 900;
	margin-left: 35px;
	margin-top: 40px;
#clock span {
	color: #888;
	text-shadow: 0px 0px 1px #333;
	font-size: 30px;
	position: relative;
	top: -3px;
	left: -4px;
	font-weight: 600px;
#date {
	letter-spacing: 6px;
	font-size: 14px;
	font-family: arial, sans-serif;
	color: #fff;
	margin-top: 30px;

	<body >
   <table border="4">
   		<td><div id="clockdate">
        <div id="clock"> </div>
        <div id="date"></div>
   	<script type="text/javascript">

Are you getting any error messages in your console? I don’'t have an IE8 instance I can test things with at the moment.

It looks like window.onload isn’t implemented in IE8, so the functions won’t run. Will need a bit of digging to understand what the alternative is. You may need to do a little feature detection.

This may help -

There is no Error in console and this programe is run successfully in Chrome and other browser even on other system in IE8 it will works but on the this system not working i there is some setting of browser something is blocking or some else i don’t understand

Maybe this will give a clue:

if this not implemented than why this is working on IE on system but not work in specific system…

You’re going to have to describe the systems you’re referring to, as I don’t think we can help diagnose things otherwise.

System is window 7 just like normal system the code is paste in notepad and run

If it works on other systems running the exact same browser then the problem is with your browser. Did you disable JavaScript?

Also, stop supporting IE8.


…is the right answer

Plz where I can check supporting Java script enable? And what u mean by stop support in i8? Plz explain

It is an obsolete browser. Microsoft themselves don’t support it any longer, why would anyone else?
People still using it are a tiny minority. Plus old unsupported browsers are a security risk to their users. As a developer, dropping support will help goad the die-hard users to finally give it up and move on to a modern browser. This in turn helps us all, so we no longer need to even think about supporting older browsers.


This. Not only that, it’s a major productivity leak, not only for yourself but others as well. The problem with supporting IE8 (or other tech no longer supported the industry) is that you suck peoples time. I’m not hating on you at all, I’m just informing you, but here are the facts:

  • This post has 137 views, meaning a lot of people wasted time reading about something that’s totally unsupported
  • It also has 13 replies, meaning people wasted energy responding to something that’s totally unsupported
  • You still haven’t solved it, meaning you’ll continue to waste both time and energy on something that’s totally supported.

IE8 is totally unsupported.

1 Like

Ok thnx for reply but my question is that why this is working on other systems which has also i8 this mean s that there is some setting issue for which I take help from this forum

I think that I’ve spotted the problem, and it’s all to do with the onload line.


When the startTime() function is executed, it returns undefined. When IE8 executes the line, it looks at you wanting to assign undefined to the onload event, and gives you an error:

SCRIPT16385: Not implemented
ie8-onload.html (85,5)

IE8 throws the error because assigning undefined to the onload event is not valid.

Other browsers execute the startTime() function, and then silently ignore the problem when undefined is returned from the function.

What should be done instead is to assign a function to the onload event, such as with:


That will have no error then.

Another solution to all of this is to remove the onload part and place the script at the end of the body (just before the tag. You can then execute the code from there without the onload part. That way the code gets to run even sooner, without needing to wait for the onload event to eventually occur.


Either of those two solutions will work better than what you currently started with.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.