No it is possible to change tabs, due to browser security precautions.
But in any case if it helps you, there is a way to detect if the system page is or is not currently active, via Visibility API .
Add the code below:
<script>
var vis = (function(){
var stateKey, eventKey, keys = {
hidden: "visibilitychange",
webkitHidden: "webkitvisibilitychange",
mozHidden: "mozvisibilitychange",
msHidden: "msvisibilitychange"
};
for (stateKey in keys) {
if (stateKey in document) {
eventKey = keys[stateKey];
break;
}
}
return function(c) {
if (c) document.addEventListener(eventKey, c);
return !document[stateKey];
}
})();
</script>
With this, you can retrieve the status of the page as follows:
<script>
var visible = vis();
</script>
And your variable visible
will now contain the value 'Visible'
or 'Not visible'
according to the status of the active page at the moment.
If you want to see how it works you have a demo page that changes the page title when it is focused / blurred.
I hope I have helped.
[Remembering that the above code refers to javascript and not php as it speaks in the question]