How to code a script that points you to the previous scene (JS)

I know how to code a script that points you to a scene, for example

MainMenu -

var options=false;

function OnMouseUp()
{
	if (options==true)
	{
		Application.LoadLevel("Options");
            //Loads the scene named Options if clicked
	}
}

Options -

        var mainMenu=false;
        
        function OnMouseUp()
        {
        	if (mainMenu==true)
        	{
        		Application.LoadLevel("MainMenu");
                    //Loads the scene named MainMenu if clicked
        	}
        }

What i currently have for options is a function that will load a certain scene if true.
I don’t want it to point you to a scene if true, i want it to point you to the previous
scene. Can you code something that points you to the previous scene you were in?

Why do i want something like this? for example, if i have a main menu scene with an options button that will load the options scene, and if i have a game level scene that has a menu with an options button that will load the options scene, i can only have the options scene point the player to the game level scene, or the main menu scene. I hope that makes sense!

You want a static variable indicating the last scene visited. In C#

public static int lastLevel;

void OnMouseUp (){
    if (options==true) {
        lastLevel = Application.loadedLevel;
        Application.LoadLevel("Options");
    }
}

// In your options script call
Application.LoadLevel(OtherClass.lastLevel);