问题
In an ongoing project (Windows, .NET C#) we encountered a bottleneck in our development: we have to observe the change of the current tab in all major browsers (IE,FF, Chrome, Opera, Safari).
As soon as tab change event has been captured, it must be written to a file.
Is this feasible?
回答1:
What i finally did was the following:
tracked the EVENT_OBJECT_NAMECHANGE for the Window title
as soon as the title gets changed i know there was something "new" loaded, so i checked for the URL of the browser using various techniques (nDDE for Firefox and Opera, checking for a specific Window Class for Chrome, etc...! Thorsten is right by saying that it's impossible, so i implemented only for the major browsers)
回答2:
I don't know how this should be done... One thing you could try is to find the window handle of the browser's tab control and hook into it, but that's quite a nasty task. And there's no guarantee that they don't use a custom tab control, so I'd say this can't be done.
Can you give some more information on why you need this? Maybe there's some other solution you didn't think of?
回答3:
You can combine these two to get what you want:
Is there a way to detect if a browser window is not currently active?
And:
Javascript; communication between tabs/windows with same origin
来源:https://stackoverflow.com/questions/14436215/hook-into-tab-changed-event-of-browser