Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

javascript onbeforeunload

  • 08-08-2006 12:33pm
    #1
    Banned (with Prison Access) Posts: 19


    Hi there,

    I am using javascript's onbeforeunload in order to create a pop up box that asks the user if they are sure they want to leave the page and tells them that their transaction will be cancelled upon leaving.
    I need it to do the following:
    if the user cancels: do not reload the page, but stay on it.
    if the user says ok, they want to leave, carry out a function and then take them to a specific page.
    I cannot use onunload as the user cannot cancel without reloading the page(as they have already unloaded)
    so I am using onbeforeunload. But with this the pop up dialogue is automatic and reloads to the previous page.
    I want to find out whether the user clicked ok or canel and on ok I want to carry out some other code before they move on to the next page. I don't want to carry out this code until they have actually pressed ok to the "do you want to leave?" dialogue.
    I am wondering
    a) how do I find the result of that dialogue that is produced by onbeforeunload?
    b) How do I get the program to run other code after the user clicks on ok in this dialogue.
    Thanks a milllion for your help ( in anticipation of said help)


Comments

  • Moderators, Politics Moderators Posts: 40,351 Mod ✭✭✭✭Seth Brundle


    try this - its not ideal but anyhow!
    Try changing it to suit your needs.
    <head>
    <script language="JavaScript">
        function function1() { 
            //var cl = confirm("are you sure you want to close the window?");        
    	
    	//if(cl==false){do something...}
        }
    </script>
    </head>
    <body onbeforeunload="function1();return false">
        gsdfgsdfg
    </body>
    </html>
    


Advertisement