How do I call a Unity function from HTML using JavaScript?

I have my Unity web player embedded in an HTML document online. How would I call a function within Unity, using Javascript in the HTML?

For example, I click a button in the HTML and a function within Unity is called.

I know the opposite of what I’m trying to do is Application.ExternalCall, but how do I call functions from Unity?

To answer it myself: You have the function in a Monobehaviour, and have the monobehaviour in the scene, and use:

var unity = GetUnity();
unity.SendMessage("ObjectWithFunctionToCall", "FunctionName", paramsToSend);