I have an application that is used on the web. It consists of a $$ViewTemplateDefault form with an embedded view. The view is an HTML view. Several fields are wrapped in input tags to allow the user to change values. When a value changes, the onChange event kicks off an agent that saves the backend document. This agent writes it’s output to a hidden iframe on the form. Works great so far.
However, if the user steps away long enough for the session to timeout, when they come back, the screen looks like the same so they don’t know it’s timed out. They can continue to enter numbers. However, the agent won’t kick off because the user session has timed out and none of their values are saved. I’m trying to find some way of letting the user know the session has timed out. How can I check if the session is still active using javascript (or any other method)?
One thing I tried was at the start of the onChange event, to check the agent output iframe for the username field. However, I can’t get it to work. No matter what I do, the user is still able to merrily enter their numbers without knowing nothing is being saved.
Here’s the function that saves the record (where I attempted to look for the login fields.)
function saveRecord(docNumber) {
var form = window.document.forms[0];
var server = form.Server_Name.value;
var dbpath = form.webDB.value;
var docID = eval('document.forms[0].Docunid_' + docNumber + '.value');
var A1 = eval('document.forms[0].A1_' + docNumber + '.value');
var A2 = eval('document.forms[0].A2_' + docNumber + '.value');
var A3 = eval('document.forms[0].A3_' + docNumber + '.value');
var A4 = eval('document.forms[0].A4_' + docNumber + '.value');
var agentPath = “//” + server +“/” + dbpath + “/saveDoc?openagent&unid=” + docID + “&A1=” + A1 + “&A2=” + A2 + “&A3=” + A3 + “&A4=” + A4;
document.getElementById(“agentOutput”).src = agentPath;
//now check the iframe for a username field. if it exists, we’ve been logged out.
var loggedOut = window.document.Username;
if (loggedOut) {
//alert (“logged out”)
}
else {
//alert (“not logged out”)
}
}
I’ve tried many combinations of those last few lines and nothing worked. Am I doing something wrong? (Obviously I am but I don’t know what!) Any ideas? Or any other suggestions as to how I could do this? This is driving me crazy!