var isDirty = false; function setDirty() { isDirty = true; } function clearDirty() { isDirty = false; } function checkDirty() { if (isDirty) return L_PageIsDirty; } window.onbeforeunload = checkDirty;