Short answer:
99% of the time, it won't be a good UX.
My choice would be to notify the user:
- Pasively when leaving the tab and
- Actively when leaving the page
Unnecesary long answer:
Why? Here some thoughts and recommendations that come to my mind:
What does the user expect?
You must think in what kind of programs the users of the application could be familiarized with, and follow a similar a approach or try something that may be better (easier, clearer, more intuitive,etc).
For sure and as mentioned in previous answers, what you should not do is to make implicit non-intuitive actions that tend to get the user mad or disoriented.
Unnecessarily undoing actions that the user may want to preserve for later saving/confirmation is definitely a thing to avoid.
Some possible solutions:
1) Inform about the app behavior (before users' action): The behavior should tend to be intuitive and without a need of notes of use, but in some cases it is necessary or at least an aggregate that has more benefits than drawbacks on the UX. Something like "The edited content will be discarded when leaving tabs without saving"
In this case, I don't find it appropiate at all.
2) Notify them that there's unsaved modified content (after users' action):
When?:
- a) When leaving the tab
- b) When leaving/changing the page
How?
a) Actively: Leaving no choice but to choose in the moment they are
leaving the tab/page.
b) Pasively: With some warning that tells the users about it
"constanstly" but without a demand of a instant response. Depending on your UI design and application there are several things you could do: changing some style of the unsaved tab (btw I dont't think that an * is always enough by itself for non-developers users) for example, some colour or any more reconigzable sign would be beneficial aggregate, even more if you have a "reference bar" with that saids "Unsaved tabs" with a reference of the unsaved-tab-color (this last things, if the amount of editable tabs is considerable, not just one or two).
Other things that may help in some particular cases:
Is the current criteria for dividing the content in tabs appropiate?
How each tab is related?:
As a user, if I'm editing something in a tab, I wouldn't like to
need to go to another tab to find some information to complete my
action (like keeping coherence between two settings which are placed
in different tabs). So the less coupled the tabs are, the better. By
doing that, the existence of unsaved content could be reduced.
The user's tendency to move between tabs in order to complete an action may be a good reason to reanalyze the information distribution within them.
"Ok I did my best, but what if it is wrong?
Test it, learn from it and improve it. You can track the user behavior to try to find a clue about what they tend to do, and modify your application based on that.