rameshfaj Posted November 10, 2008 Share Posted November 10, 2008 I have used window.onbeforeunload() to alert user that they will lose the changes if navigate away from the page. But the alert dialog is displayed twice instead of once. What might be the cause and what will be the possible solution for this? can any one help me? Quote Link to comment Share on other sites More sharing options...
F1Fan Posted November 10, 2008 Share Posted November 10, 2008 Could you show us some code? Quote Link to comment Share on other sites More sharing options...
rameshfaj Posted November 11, 2008 Author Share Posted November 11, 2008 Here you can find the portion of the code: var canExit = <%=formObj.getDealID()==null || "".equals(formObj.getDealID())%>; var unloadFXFlag = true; var cancelDealFlag = true; window.onbeforeunload =checkFXDeal; function checkFXDeal(){ try{ alert(<%=formObj.getDealID()%>); } catch(e){} if(!canExit && unloadFXFlag) return "WARNING: You have established an FX deal. Exiting without creating a transaction requires cancellation of the FX deal. Do you wish to continue?"; } The javascript variable canExit is initialized by the attribute of the java object. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.