Notification in HTML5

How can it be done so that in a network game, when switching to another tab, it would be possible to receive a notification from the game, such as a message about a found game or an opponent was end turn?

You can use browsers push notification api by calling js functions from Defold.