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.