<script type="text/javascript">
var startTime = new Date();
var TimeTaken;
//Start the clock!
window.onbeforeunload = function ()
{
var endTime = new Date();
//Get the current time.
var timeSpent = (endTime - startTime);
seconds = (timeSpent / 1000) % 60;
TimeTaken = parseInt(seconds);
//return TimeTaken;
var temp = document.getElementById('<%=Label1.ClientID %>').value;
temp = TimeTaken;
alert(temp);
<%PageO(); %>
};
The above JS file runs when I close the tab/page in browser. But the function Which I called <%PageO(); %>
executes when the programs starts running itself. This function call in code behind(C#) should execute only when the tab/page is closed not at the start of the program.
Any mistakes in this code?