Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
473 views
in Technique[技术] by (71.8m points)

jquery - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...