How to handle unsuccessful redirection

How do I handle failed redirections in javascript?

Basically I have like 3""). Before doing this, user must login first and then run this html file. (don't mind this login thing in for my question)

However for the logic of the goal, if the first"") isn't right then it will redirect the user into logout which is in my case, what I want to is do is to prevent the redirection for the logout and just proceed to my second"").


function func()