Hi
I will try to explain my problem :
I need to store time that user spend on every page ...
So when user leave a page or close it I have to calculate spent time and store it in DataBAse.
As I found it could be done with script that on wwindow.onbeforeunload do somthing
I create .net user control that don't have anything that else just script and on page load in script I create var START= new DATE();
so after that I will call a page form javascript and on it trough request string store time in Database....
here my jscript code
Quote:
var XmlReq;
// This page returns the XML Response for the selected choice
var AjaxServerPageName = "./usercontrols/dvvUtilities/storageSpendTime.aspx";
window.onload = startClock;
window.onbeforeunload = confirmExit;
function CreateXmlReq() {
try {
XmlReq = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
XmlReq = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (oc) {
XmlReq = null;
}
}
if (!XmlReq && typeof XMLHttpRequest != "undefined") {
XmlReq = new XMLHttpRequest();
}
}
var startTime;
function startClock() {
startTime = new Date();
CreateXmlReq();
}
function confirmExit() {
exitTime = new Date();
diff = new Date();
timeString = "";
var timediff;
diff.setTime(Math.abs(exitTime.getTime() - startTime.getTime()));
timediff = diff.getTime();
hours = Math.floor(timediff / (1000 * 60 * 60));
timediff -= hours * (1000 * 60 * 60);
mins = Math.floor(timediff / (1000 * 60));
timediff -= mins * (1000 * 60);
secs = Math.floor(timediff / 1000);
timediff -= secs * 1000;
timeString = hours + ":" + mins + ":" + secs ;
alert(timeString);
var requestUrl = AjaxServerPageName + "?time2string=" + timeString;
CreateXmlReq();
if (XmlReq) {
XmlReq.onreadystatechange = HandleResponse;
XmlReq.open("GET", requestUrl, true);
XmlReq.send();
}
}
function HandleResponse() {
if (XmlReq.readyState == 4) {
if (XmlReq.status == 200) {
}
else {
alert("There was a problem storing data to the server.");
}
}
}
so everything is ok ....when user close or leave a page code calculate time spend BUT when I whant to call a page that will extualy write that result in Database it seams that umraco can call it WHY???
What I do wrong ?