Possible to set tab focus in IE7 from JavaScript

前端 未结 5 912
逝去的感伤
逝去的感伤 2021-01-23 14:33

Is it possible to launch a new window in JavaScript using the window.Open function, then set the focus to that tab?

Here\'s what I\'m doing today:

             


        
相关标签:
5条回答
  • 2021-01-23 15:23

    If the other "tab" is part of your application (and not content from another site) perhaps you should include it in a popup div on top of your main content instead of in a separate window; that way you can always control focusing it, deactivating the content under it (for modal dialogs), hiding it, etc.

    0 讨论(0)
  • 2021-01-23 15:23

    As a user, shouldn't I be able to control how this operates?

    What if there is an application that would be enhanced by this feature that I want to run - shouldn't I be able to grant a domain that privilege?

    Just a thought.

    0 讨论(0)
  • 2021-01-23 15:25

    Jay,

    You are seeing designed behavior. To limit opportunities for malicious behavior, scripts running in tabbed windows cannot affect other tabs.

    For more information, please see Tabbed Browsing for Developers at http://msdn.microsoft.com/en-us/library/ms537636.aspx :

    "The ability to open multiple documents within the same browser window has certain practical and security implications [...] Active tabs (tabs with focus) cannot be affected by scripts that run in inactive or background tabs."

    BR.

    0 讨论(0)
  • 2021-01-23 15:30

    I'm reasonably certain you can't shift focus to another tab.

    My understanding is this is done to somewhat limit pop ups and other malicious content from stealing the users focus.

    0 讨论(0)
  • 2021-01-23 15:32

    As a user, I never want applications (or tabs) to take focus unless I specifically requested it. I have gone to great lengths to prevent tabs in my browser (Firefox) from taking focus for this reason.

    0 讨论(0)
提交回复
热议问题