1

I have this code to do a window.focus(); or a self.focus(); to stay on the current window to show a message before going to the newly opened window. This works fine on Safari. The browser pauses on the original window for the specified time before going to the new window. On Internet Explorer the browser ignores the self.focus(); call completely, does the same for window.focus();. Is there a different way in IE to stay or focus on the current window.

    if ( show_message == true ) {
        var message_page = "livemass_message.php?message_id="+message_id;
        message_window = window.open (message_page,'_blank','width=600,height=200,top=200,left=300,alwaysRaised');
        self.focus();
        setTimeout(function() { external_window.focus(); message_window.focus(); }, 3500);
        setTimeout(function() { message_window.close(); }, 60000);
    }
    else {
        self.focus();
        setTimeout(function() { external_window.focus(); }, 3500);                      
    }
user823527
  • 3,644
  • 17
  • 66
  • 110
  • These answers might contain usefull information: http://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus – Teemu May 16 '12 at 20:07
  • @Sagiv I haven't defined self. On Safari the browser seems to know that self is the current window. How do I define self? – user823527 May 16 '12 at 22:26

1 Answers1

0

I had to do this when my page auto-refresh each 5 minutes (so, in body onload), to be sure the window is on top. The following works for me (tested with Internet Explorer only):

top.document.body.focus();
Matt Roy
  • 1,455
  • 1
  • 17
  • 27