Closed Bug 209037 Opened 21 years ago Closed 21 years ago

Bookmarklet "javascript:window.find()" is broken.


(SeaMonkey :: UI Design, defect)

Not set


(Not tracked)



(Reporter: PierreDeKat, Assigned: neil)




(Keywords: fixed1.8)


(3 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030529
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030529

Ref: search toolkit.jar for "window.find()"

At one time, a method was implemented for calling up Mozilla's "Find in this
Page" dialog via a bookmarklet "javascript:window.find()" but that method no
longer appears to work. The dialog is called up, but Mozilla makes no attempt to
actually search for the text that is entered into the dialog box.

Reproducible: Always

Steps to Reproduce:
1. Create bookmarklet "javascript:window.find()"
2. Open a webpage containing text
3. Launch said bookmark
4. Enter text into "Find in this Page" dialog box
5. Click Find

Actual Results:  
Mozilla makes no effort to search document for text entered into "Find in this
Page" dialog box.

Expected Results:  
Mozilla should have searched the document for the text entered into the "Find in
this Page" dialog box.

A variety of other bookmarklets -- including "javascript:void(find())" and
"javascript:(function(){find();})()" -- work similarly, pulling up the FITP
dialog, only to have Mozilla ignore the requested search.
Sounds like a focus problem to me....  The content area does not have focus, so
the find dialog gets hooked up to nothing useful  (my guess).
Using the JS console to force focus with
top.getTopWin().content.focus();top.getTopWin().content.find(); also fails.
I was just noticing that I may have quoted the script differently than what I
was using at the time. I think I was actually trying
"javascript:void(window.find())" when I came to the conclusion that there must
be a problem somewhere.

Interestingly, "javascript:window.find()" works flawlessly in Netscape 4.79, as
does the simpler "javascript:find()", as does "javascript:void(find())", as does
"javascript:(function(){find();})()". So there are at least four different ways
of accomplishing the task in NN4, but none that work in Mozilla.
I can't get window.find() to work within web page as well. moz2004013108/win2k
Component: Bookmarks → DOM: Level 0
Ever confirmed: true
Assignee: p_ch → general
QA Contact: chrispetersen → ian
Attached file Testcase
This shows that this only happens when the find dialog is involved.
window.find('some text') works fine.
This is not a DOM bug. Looks like a regression from bug 127589.
Component: DOM: Level 0 → XP Apps
Assignee: general → jag
QA Contact: ian → pawyskoczka
Attached patch Proposed patchSplinter Review
The way that the find dialog was testing for how it was opened caused this:
JavaScript error:
chrome://global/content/finddialog.js line 91: invalid 'instanceof' operand
Assignee: jag →
Attachment #140368 - Flags: superreview?(jag)
Attachment #140368 - Flags: review?(timeless)
Attachment #140368 - Flags: review?(timeless) → review+
Comment on attachment 140368 [details] [diff] [review]
Proposed patch

Attachment #140368 - Flags: superreview?(jag) → superreview+
Fix checked in.
Closed: 21 years ago
Resolution: --- → FIXED
Product: Core → Mozilla Application Suite
This was never fixed for Firefox. The bookmarklet case is an instance where the
old find dialog is still used.
Attachment #196181 - Flags: review?(mconnor)
Attachment #196181 - Flags: approval1.8b5?
Comment on attachment 196181 [details] [diff] [review]
patch for Firefox

please don't request approval until you've got appropriate reviews.
Attachment #196181 - Flags: approval1.8b5?
Attachment #196181 - Flags: review?(mconnor) → review+
Whiteboard: [checkin needed]
Comment on attachment 196181 [details] [diff] [review]
patch for Firefox

This should be safe, since this patch is already since very long in Seamonkey.
Attachment #196181 - Flags: approval1.8b5?
mozilla/toolkit/content/finddialog.js; new revision: 1.12;
Whiteboard: [checkin needed]
Comment on attachment 196181 [details] [diff] [review]
patch for Firefox

Per bug meeting - approved for 1.8b5 branch.
Attachment #196181 - Flags: approval1.8b5? → approval1.8b5+
1.8 Branch:
mozilla/toolkit/content/finddialog.js; new revision:;
Keywords: fixed1.8
You need to log in before you can comment on or make changes to this bug.