Please could you help a JS and Domino newbie?
I set up document locking for a web application.
It creates locking documents by running a LS agent in the WebQueryOpen event.
The locks are called by a closeDoc() function which runs a removeLock LS agent.
The locking docs are created as expected.
For testing I called the closeDoc() function in the ONUnload event of the form. This works nicely - even if the user closes the browser, the lock is removed - which is correct.
However, as we plan to add keywort type of fields, which require document reload on keyword change, having the closeDoc() function in the OnUnload event is a bad idea (docuent closing on doc refresh).
I tried using the OnFocus and OnBlur fields to set a flag then check the flag in OnUnload before running closeDoc(). The JS in OnFocus seems to run fine setting the flag and resulting in bypassing the closeDoc function in OnUnload.
However, the OnBlur JS code doesn’t seem to run - the flag is not reset resulting in closeDoc() function not running when the document needs to be closed.
Am I breaking any ‘rules’ by using this setup?
Is there a way to reset the flag? - maybe in another event…
Alternatively, I would consider a different approach to this problem… Any suggestions?
Code:
JS Header:
function closeDoc()
{
if (frm.mode.value==1)
{
window.location= frm.DBPath.value + "/RemoveLock?OpenAgent&user=" + frm.originator.value + "&unid=" + frm.UNID.value;
window.location = frm.DBPath.value + "/main?OpenFrameset";
}
}
OnUnload:
var x=document.getElementById(“bypassClose”).value;
if(x = “”)
{
closeDoc();
}
document.getElementById(“bypassClose”).value=“”;
OnFocus (of the combobox field):
var x=document.getElementById(“bypassClose”).value;
document.getElementById(“bypassClose”).value=“Yes”;
OnBlur (of the combobox field):
var x=document.getElementById(“bypassClose”).value;
document.getElementById(“bypassClose”).value=“”;
Thanks