You can't.
Switching tabs is beyond what content-level JavaScript has security permissions to do. As far as one JavaScript instance is concerned, there only exists one tab (window
).
You would need to write an extension for your browser of choice.
If you're writing for Chrome, check out some documentation on the APIs for tab manipulation with extensions.