Browser SendMessage problem

Hello.
I’m trying to send a message to Unity from the browser.
I’m using the example of the documentation literally, and I think to have followed all the steps.

In Chrome I get the message: “Uncaught TypeError: Can not call method ‘SendMessage’ of null”

And the expressions inspector of Safari says “unity.SendMessage: ReferenceError: Can not find variable: unity”

It is as if unityObject.getObjectById (“UnityContent”); did not work.

Any idea?

this one works :

		function GetUnity() {
			if (typeof unityObject != "undefined") {
				return unityObject.getObjectById("unityPlayer");
			}
			return null;
		}
		if (typeof unityObject != "undefined") {
			var params = {
				disableContextMenu: true
			};
			unityObject.embedUnity("unityPlayer", "WebPlayer.unity3d", 1024, 768, params);
			
		}

and then :

var unity = GetUnity();
unity.SendMessage("…

Thanks appels!
I’ll try it now.

It works! (both in Chrome and Safari)

Maybe the documentation could be more clear on this subject…
It say you must use unityObject.getObjectById() but it seems not working properly.

Thanks again appels!

yeah sometimes you have to try some things lol