SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with self.focus(); on Firefox

    Hello
    I have a parent page that opens a popup (chat) i wont that where someone send a msg to a user the popup to get focused.

    I have a function on popup window that runs everytime a user get msg I put "self.focus()" on that function and this work fine in IE but not in Firefox.

    Do someone know a way to fix this?

  2. #2
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you opened a popup through JavaScript, the window.open() function returns a reference to the new window itself.
    You can set focus to the window by doing this:
    Code:
    var myWin = window.open(...);
    myWin.focus();
    As I remember it well, you have to use window.focus() instead of self.focus() in the new popup window itself.
    FOR SALE: 1 set of morals, never used, will sell cheap

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by hexburner View Post
    If you opened a popup through JavaScript, the window.open() function returns a reference to the new window itself.
    You can set focus to the window by doing this:
    Code:
    var myWin = window.open(...);
    myWin.focus();
    As I remember it well, you have to use window.focus() instead of self.focus() in the new popup window itself.
    If I use window.focus(); I got the message that the object isnt defined.
    Try self and see, im using Firefox 2.0.0.4

  4. #4
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Indeed, it doesn't work in FF 2.0.0.x, it does in previous versions... But now it's unsupported.
    Actually, I'm glad it's not supported by FF 2, the web will be a better place.
    FOR SALE: 1 set of morals, never used, will sell cheap

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by hexburner View Post
    Indeed, it doesn't work in FF 2.0.0.x, it does in previous versions... But now it's unsupported.
    Actually, I'm glad it's not supported by FF 2, the web will be a better place.
    hehe found that you have to set this function "dom. disable_window_flip" to "false" in about:config and then it will work.

    Thanks a lot that you try to help

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The standards do not require the focus event to be supported for windows - only for <a> and form field elements. That some browsers support window.focus just means that those browsers have implemented additional browser specific functionality which cannot be relied on to work in all browsers. For some reason the different browsers haven't even implemented focus and bluur consistently so that more browsers support focus with windows than support blur.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •