Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute statement after return statement in Javascript

window.onbeforeunload = function() {
    if (document.getElementById("parentpan").style.display == "block") {
        return "You are logged out.";
            Logout();
    }
};

I want the logout() function to be called after the return statement, is it possible?

like image 723
Faisal Amjad Avatar asked Dec 31 '12 14:12

Faisal Amjad


1 Answers

You can't execute anything after a return statement.

edit: the finally statement allows code execution after a return for cleanup purposes.

(This is a good example for an XY-Question: You are asking about Y while never telling us for what X you actually need it).

like image 120
Femaref Avatar answered Sep 27 '22 20:09

Femaref