Closed Bug 108394 Opened 23 years ago Closed 8 years ago

window opened by bookmarklet loses focus when bookmarklet finishes


(Core :: DOM: Core & HTML, defect)

Not set





(Reporter: jruderman, Unassigned)




(Keywords: helpwanted, regression)

Steps to reproduce:
1. Type "; void 0" into the location bar and press 

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

This breaks many of my bookmarklets (
Keywords: regression
I can confirm this on MacOS 9, Mozilla 0.9.7.

Another test-case:
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.
Blocks: 88810
Please reassign as necessary
Assignee: neeti → jst
Component: Networking → DOM Level 0
QA Contact: benc → desale
Focus problem, over to bryner.
Assignee: jst → bryner
*** Bug 109925 has been marked as a duplicate of this bug. ***
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?
Mozilla 2002020703, Windows 2000.
the browser appears to do absolutely nothing when I give it
'; void 0'

but 'javascript:open('','','width=350,height=180'); void 0' atleast momentarily
creates a little window which then disappears, focus doesn't change
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); 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
Keywords: nsbeta1
ADT triage team needs info: Is this happening on any top sites?
Whiteboard: [need info]
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]
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.
I should hope it doesn't affect the common prompt(); bookmarklet. As it is, losing focus is merely the Wrong Thing to do. If /prompts/ popped
behind windows, that would be Bad and Wrong. :)
nsbeta1- per Nav triage team
Keywords: nsbeta1nsbeta1-
Summary: javascript: url steals focus when it finishes running → window opened by bookmarklet loses focus when bookmarklet finishes
*** Bug 154939 has been marked as a duplicate of this bug. ***
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
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.
Nav triage team: nsbeta1-
Keywords: nsbeta1nsbeta1-
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 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?
*** Bug 161063 has been marked as a duplicate of this bug. ***
This regression might have been caused by the fix for bug 96592, "remove focus
on url-bar after loading a bookmark".
*** Bug 151316 has been marked as a duplicate of this bug. ***
*** Bug 239838 has been marked as a duplicate of this bug. ***
anyone know a workaround for this? thanks.
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:
----; void 0

But, the following code works as intended (with the new window keeping focus):
[Code for Furl bookmarklet -]

any ideas on a fix?

The unhighlighting of the bookmark/url idea is a good one, but I'm not sure,
since the above code works without a hitch. 
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
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.
Closed: 8 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.