window opened by bookmarklet loses focus when bookmarklet finishes

RESOLVED WORKSFORME

Status

()

Core
DOM: Core & HTML
--
major
RESOLVED WORKSFORME
16 years ago
a year ago

People

(Reporter: Jesse Ruderman, Unassigned)

Tracking

({helpwanted, regression})

Trunk
helpwanted, regression
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

16 years ago
Steps to reproduce:
1. Type "javascript:window.open(); void 0" into the location bar and press 
enter.

Result: new window opens in back of current window.
Expected: new window opens in front of current window.

This breaks many of my bookmarklets (http://www.squarefree.com/bookmarklets/).
(Reporter)

Updated

16 years ago
Keywords: regression

Comment 1

16 years ago
I can confirm this on MacOS 9, Mozilla 0.9.7.

Another test-case: http://www.leo.org/dict/bookmarklet_en.html
1. Drag the "Leo Dict" link to your personal toolbar
2. Make a selection of a word somewhere on the page
3. Click your new toolbar icon
Result: the new window opens behind the old

Note 1: If you mark a word, and then directly click the "Leo Dict" link on the
page, the new window correctly opens in front.
Note 2: The "Leo Dict" javascript line even includes a focus(), but that does
not seem to help.

Updated

16 years ago
Blocks: 88810

Comment 2

16 years ago
Please reassign as necessary
Assignee: neeti → jst
Component: Networking → DOM Level 0
QA Contact: benc → desale
Focus problem, over to bryner.
Assignee: jst → bryner
(Reporter)

Comment 4

16 years ago
*** Bug 109925 has been marked as a duplicate of this bug. ***

Comment 5

16 years ago
The pseudo-URL listed for this bug works as expected in 2002012206-trunk on
Windows 98, but the following still loses focus immediately when called from the
location bar:

javascript:open('','','width=350,height=180'); void 0

Is anyone else seeing this behavior in other platform/OS combinations?

Comment 6

16 years ago
Mozilla 2002020703, Windows 2000.
the browser appears to do absolutely nothing when I give it
'javascript:window.open(); void 0'

but 'javascript:open('','','width=350,height=180'); void 0' atleast momentarily
creates a little window which then disappears, focus doesn't change

Comment 7

16 years ago
I'm really sorry. I didn't have my lameness filter on when I wrote the previous
comment. I wasn't seeing the windows being created in the background as I'm so
used to using browser tabs and was expecting them to come up as tabs. I apologise.
[Mozilla 2002020908, Windows 2000)

javascript:window.open(); void 0
opens behind current window

javascript:open('','','width=350,height=180'); void 0
opens momentarily in front of current window but quickly shifts to behind

Updated

16 years ago
Keywords: nsbeta1

Comment 8

15 years ago
ADT triage team needs info: Is this happening on any top sites?
Whiteboard: [need info]
(Reporter)

Comment 9

15 years ago
No, this bug only affects bookmarklets.  In fact, it only affects bookmarklets
that open new windows, and doesn't affect the more common "google search" and
"dictionary lookup" bookmarklets.
Whiteboard: [need info]

Comment 10

15 years ago
When I was in the habit of testing Windows builds, I never saw the problem on
any top sites. Of course, it's hard to tell, since many sites seem to want this
behavior now (e.g., pop-under ads), and I have turned off the ability to spawn
new windows with the onload event in my prefs. Very rarely do I see any sites
that want to spawn a new window with these small dimensions using JavaScript.

Unfortunately, I am not able to test Windows binaries at the present time, and I
have never seen this issue in GNU/Linux builds.

Is this behavior still exhibited in MacOS 9 builds? The platform and OS should
have been changed to all with comment #1.

Comment 11

15 years ago
I should hope it doesn't affect the common prompt(); bookmarklet. As it is,
window.open() losing focus is merely the Wrong Thing to do. If /prompts/ popped
behind windows, that would be Bad and Wrong. :)

Comment 12

15 years ago
nsbeta1- per Nav triage team
Keywords: nsbeta1 → nsbeta1-
(Reporter)

Updated

15 years ago
Summary: javascript: url steals focus when it finishes running → window opened by bookmarklet loses focus when bookmarklet finishes
(Reporter)

Comment 13

15 years ago
*** Bug 154939 has been marked as a duplicate of this bug. ***

Comment 14

15 years ago
Changing Platform and OS to all, based on the most recent dupe.

Also please note, per Peter's question in Comment #8, that I would consider
Blogger (cf bug 154939) to be a top site.
OS: Windows 98 → All
Hardware: PC → All

Comment 15

15 years ago
After considering the latest dupe to this bug, I've reset the nsbeta1- keyword
back to nsbeta1 for reconsideration by the nav triage team. See Comment #14. If
nsbeta1 was rejected for lack of any top sites, I think we've seen that now.

Also adding nsCatFood and helpwanted.
Keywords: nsbeta1- → helpwanted, nsbeta1, nsCatFood

Comment 16

15 years ago
Nav triage team: nsbeta1-
Keywords: nsbeta1 → nsbeta1-

Comment 17

15 years ago
I had originally thought that this might be caused by the URL bar on the 
original window gaining focus. I tried hiding the "Navigation bar" and testing, 
but got the same results.

Looking carefully at what's happening here, it appears that focus switches back 
to the original window in order to unhighlight the bookmarklet. Here's the 
sequence of events:

Add a javascript window.open bookmarklet to the personal toolbar
Click and hold the bookmarklet
- Nothing has happened yet
Release the mouse click
- The bookmarklet is still highlighted as the new window is opening
- The new window opens and is on top for a flash
- It switches back to the original window and unhighlights the bookmarklet

Is the right way to fix this to have the bookmarklet unhighlight immediately 
and then do the bookmarklet action? Why does the original window gain focus? Is 
there still code there that forces a switch back?
(Reporter)

Comment 18

15 years ago
*** Bug 161063 has been marked as a duplicate of this bug. ***
(Reporter)

Comment 19

15 years ago
This regression might have been caused by the fix for bug 96592, "remove focus
on url-bar after loading a bookmark".
(Reporter)

Comment 20

15 years ago
*** Bug 151316 has been marked as a duplicate of this bug. ***
(Reporter)

Comment 21

13 years ago
*** Bug 239838 has been marked as a duplicate of this bug. ***

Comment 22

13 years ago
anyone know a workaround for this? thanks.

Comment 23

13 years ago
I don't have a solution, but I've got a Mac OS X testcase

Firefox 0.9.3 running on Mac OS X 10.2.8 exhibits this behavior. 

the following code acts exactly as described in this bug:
----
javascript:window.open(); void 0
----

But, the following code works as intended (with the new window keeping focus):
[Code for Furl bookmarklet - furl.net]
----
javascript:(function(){var%20hd=document.getElementsByTagName('head')[0];hd?
(function(){var%20s=document.createElement('script');s.setAttribute('src',
'http://www.furl.net/resources/furlItCompleteMoz.jsp');s.setAttribute('type',
'text/javascript');hd.appendChild(s);})():window.open(
'http://www.furl.net/storeIt.jsp?t='+escape(document.title)+'&u='+escape(
document.location.href)+'&c='+escape(document.getSelection?
document.getSelection():''),'myfurlwindow','scrollbars=no,width=475,
height=575,left=75,top=20,status=no,resizable=yes');})();
----

any ideas on a fix?

The unhighlighting of the bookmark/url idea is a good one, but I'm not sure,
since the above Furl.net code works without a hitch. 
(Reporter)

Comment 24

13 years ago
Bug 232605 has a fix for the Firefox version of this bug.
Assignee: bryner → general
QA Contact: desale → ian
Assignee: general → nobody
QA Contact: ian → general

Comment 25

a year ago
User Agent 	Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
Build ID 	20160315153207

Considering bug 232605 was fixed and I can't reproduce this issue I will close the bug as WFM. If anyone can reproduce the issue on a current build, fell free to reopen it.
Status: NEW → RESOLVED
Last Resolved: a year ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.