bugzilla.mozilla.org will be intermittently unavailable on Saturday, March 24th, from 16:00 until 20:00 UTC.

Return keyword arguments from getSelection



Bookmarks & History
16 years ago
14 years ago


(Reporter: Josh, Assigned: Ben Goodger (use ben at mozilla dot org for email))


Firefox Tracking Flags

(Not tracked)




16 years ago
Many bookmarklets operate on text selected in the browser window.  Some, such as
Jesse Ruderman's "bug search"
(http://squarefree.com/bookmarklets/mozilla.html#bug_search) make the effort to
prompt for input when they are invoked with no text selected.  Others, such as
this one (sorry no source to cite handy):

<BLOCKQUOTE>javascript:var s='';if(window.getSelection)
s=window.getSelection();else if(document.getSelection)

make no allowance for no text being selected.  I propose that if a bookmarklet
is invoked by an internet keyword, then the IK's arguments (%s) should be
returned by window.getSelection and/or document.getSelection (only in the case
where no text is actually selected, of course).  This would permit bookmarklets
such as the above to be invoked from the URL bar (e.g. "dict abstruse") even
when the original author did not plan for it.

Comment 1

16 years ago
Tweaking summary, OS and platform.

I don't think this will be implemented, simply because it violates the
getSelection specification.
OS: Windows 2000 → All
Hardware: PC → All
Summary: [RFE] Make IK arguments available to bookmarklets → Return keyword arguments from getSelection

Comment 2

16 years ago
I wonder if it's possible to avoid violating the getSelection specification by
programmatically selecting the keyword's arguments like so:

1. User types keyword plus arguments into URL bar, e.g. "dict abstruse"
2. (Proceed to following steps only if the keyword points to a bookmarklet)
3. Select arguments in URL bar, e.g. "dict ABSTRUSE" (u.c. = selected text)
4. Launch bookmarklet

Currently, {window.,document.}getSelection don't appear to return text that is
selected in the URL bar, so for example if I select "show" from the URL of this
bug (http://bugzilla.mozilla.org/show_bug.cgi?id=177814) and launch the
dictionary bookmarklet in the original description, getSelection doesn't return
"show" to the bookmarklet.  Does the getSelection specification leave room for
the contents of the URL bar to be considered as part of the document?  If so
then selected URL bar text could be returned by document.getSelection with a
clear conscience.  Otherwise, I agree that the harm of violating the spec would
probably exceed the benefit of the feature.

Comment 3

14 years ago
would bug 175419 accomplish the same thing.
Last Resolved: 14 years ago
Resolution: --- → WONTFIX
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.