greg Posted January 21, 2007 Share Posted January 21, 2007 Hello Everyone,This seems so simple, but I can't figure it out.What I need is to record the real page load time of every webpage for every visitor.Firstly, I have tried to calculate the time using php, but as this is server side, I can only record the time spent on running the code, not the actual time the webpage loads in the visitor browser.Secondly, I have used javascript, and it works ok, the only problem I can’t do anything with that number. I can’t write it in the database, I can’t write it in a log file, I can’t send it by email, etc. I understand this is because when the visitor does the request, php runs first, them javascript.I need someone give a hand on this. I would like either record every time in the database, or write a log file, or send an email (this is not so good because I will get lot of emails). If anyone knows some software to do this, please post here the name.Please help me. I’m stuck with this project for about a week now.Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 You could use ajax to send the javascript var to your PHP code. Quote Link to comment Share on other sites More sharing options...
greg Posted January 21, 2007 Author Share Posted January 21, 2007 Thank you Jesirose. Do you know of any place I can get an idea of how it can be done. I have never worked with AJAX before.This is the javascript code I use for this.[CODE]dt=new Date();document.onreadystatechange=function() { if (document.readyState=="complete") { if ((PLT_Span=document.getElementById(PLT_DisplayElementID)) == null) { document.body.insertBefore(document.createElement("br")); PLT_Span = document.body.insertBefore(document.createElement("span")); } PLT_DisplayFormat = PLT_DisplayFormat.replace(/%%S%%/g, ((new Date() - dt)/1000)); PLT_Span.style.Color = PLT_ForeColor; PLT_Span.style.backgroundColor = PLT_BackColor; PLT_Span.style.fontSize = PLT_FontPix + "px"; PLT_Span.innerText = PLT_DisplayFormat; }}[/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 I like the Mootools framework. Mootools.net It makes it very easy to make ajax calls, and there are tons of tutorials for it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.