In my code a timed event launches a ModalDialog. If the user switches tabs before the event the tab blinks but that is it.
Is there a way to make the browser switch
There isn't a cross-browser way do focus a tab/window that's 100% reliable, especially in newer browsers. This would be an advertisers dream...so it's actively blocked in most newer browsers.
As a user, I'm glad it's difficult in most cases, impossible in others to do this.
There is no reliable way to do that. The Internet Explorers are the most cooperative about raising windows (which is what switching tabs amounts to), while Safari pretty much ignores all such requests. Firefox can be configured (by its user, not by your code) to allow windows to grab focus, but it's rare for anybody to do that.
You can have your code call window.focus()
but don't rely on it to work.