...

View Full Version : body onload issue



helloise
10-06-2011, 11:12 AM
i cannot understand, am i making the same mistake each time but my <body onload="startChecking()">

does not want to load again??

here my full code:


<head>
<script language="JavaScript" type="text/javascript">
var sendReq;
var receiveReq;
var lastmessage = 0;
var mTimer;

function startChecking()
{
receiveReq = new XMLHttpRequest();
console.log("1234");
getNewMessage();
}

function getNewMessage()
{
if (receiveReq.readyState == 4 || receiveReq.readyState == 0)
{
console.log(receiveReq.readyState);
}
mTimer = setTimeout('getNewMessage();',30000);
}
</script>
</head>

<body onload="startChecking()">

//more code here

</body>


i just want the console.logs to execute then i will continue with the rest of my code...

please help?
thank you

devnull69
10-06-2011, 12:14 PM
The code is absolutely fine like this. There has to be another problem ... any other Javascript on the page?

antonioatt
10-06-2011, 12:47 PM
The code is absolutely fine like this. There has to be another problem ... any other Javascript on the page?

I also tested the code (in google chrome ) and is ok, I see 1234 and various 0 in console .
In IE your code gives compilation errors (console is undefined ) and then onLoad don't work.

helloise
10-06-2011, 01:25 PM
thanks all, used window.onload and now it works...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum