1

I am using window.open to open a popup window in my Chrome extension. This works fine. But, when I include jquery-ui.js (v1.11.4) in my extension, the popup window does not focus once opened. It flashes in the foreground for a second and then moves to the background. I have tried using window.focus but I think that doesn't work in Chrome (even the workaround of using window.blur didn't work).

Same thing happens if I try to create a popup with chrome.windows.create. I'm not sure why this problem occurs only when the the jquery ui library is included. Is this a known bug?

UPDATED: My code flow is as follows:

popup.html

<DOCTYPE html>
<html>
<head>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="jquery-ui.js"></script> 
    <script type="text/javascript" src="login.js" defer></script>
</head>
<body>
     .....
</body>

login.js

displayPopup();
function displayPopup() {
   var popupWin = window.open(url, '', 'height=800, width=800, scrollbars=scroll');
   if (window.focus) {
      console.log('window has focus');
      popupWin.focus();
   }
   else if (popupWin.focus) {
       console.log('popup has focus');
   }
}

I can see that window has focus because console.log('window has focus'); is being printed. But, the popupWin.focus(); doesn't seem to be executing.

llams48
  • 387
  • 2
  • 7
  • 16
  • I'm guessing you need to show the offending code, as no, it's not a known problem but something to do with your code. Also, consider updating the window to make it focused with `tabs` API. – Xan Jul 24 '15 at 07:02
  • @Xan, thanks for confirming. As I mentioned, I tried chrome.windows.create and chrome.windows.update, and that didn't work either. I have included my code above. – llams48 Jul 24 '15 at 08:14
  • 1
    Using `window.open` from extensions is not recommended. Can you show your `tabs` attempt instead? – Xan Jul 24 '15 at 08:24
  • @Xan, I debugged this further, and it turns out that including the jquery-ui.js library in popup.html header is causing problems. If I copy-paste the library directly in login.js, it's fine. Should I be using chrome messaging instead or something else? – llams48 Aug 04 '15 at 05:45

0 Answers0