Closed
Bug 1023769
Opened 11 years ago
Closed 9 years ago
Can't access event object from bookmarklet
Categories
(Firefox :: Bookmarks & History, defect)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: vrubleg, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 6.1; rv:28.0) Gecko/20100101 Firefox/28.0 (Beta/Release)
Build ID: 20140314220517
Steps to reproduce:
1. Create bookmark with this URL:
javascript:var url='https://www.google.com/search?q=%s&sitesearch='+document.location.hostname; if(arguments[0].altKey) window.open(url); else document.location.href=url; void(0)
2. Enter keyword: on
3. Open any website
4. In address bar enter: on test
Actual results:
ReferenceError: arguments is not defined
Expected results:
Arguments have to be defined (current event object).
It would be nice to have ability to imitate default browser behaviour in bookmarklets.
I think that ability to detect event type (mouse or keyboard) also would be nice because different key modifiers used for open new tabs: ctrl+click for mouse, but alt+enter for keyboard.
As alternative I propose another solution for this problem. You can detect if bookmarklet returned an URL and open this URL with default browser behaviour (in a new or current tab according to current user settings). For example, this bookmarklet:
javascript:return 'https://www.google.com/search?q=%s&sitesearch='+document.location.hostname;
If user type "on test" and press alt+enter (if user didn't changed default keystroke), it have to open search result in a new tab. But if user type "on test" and press enter without modifiers, it have to open search result in current tab.
In addition we also can do a clickable version of this bookmarklet:
javascript:return 'https://www.google.com/search?q=' + ('%s' == ('%'+'s') ? prompt('Enter keywords') : '%s') + '&sitesearch='+document.location.hostname;
Ctrl+click have to open search results on new tab, but simple click have to open search results in current tab.
Comment 1•9 years ago
|
||
bookmarklet isn't executed as an event handler or event listener, so I don't understand why
event should be defined as param.
But anyhow, bookmarklets aren't a platform feature, but Firefox.
Component: DOM: Events → Bookmarks & History
Product: Core → Firefox
I've tested this on the latest release(43.0.4) and on the latest Nightly(46.0a1). This is reproducible but looks like is more of an enhancement. Following the given steps to reproduce "ReferenceError: arguments is not defined" message is displayed. This is not an applicable test case on Chrome, because Chrome does not have a keyword field when creating a bookmark. Can you please share your opinion on this?
Thanks,
Paul.
Flags: needinfo?(mak77)
Comment 3•9 years ago
|
||
I think the same as comment 1, bookmarklets are not run as event handlers and unless other browsers with a large userbase do that, I don't think we should do that without compelling use-cases.
Flags: needinfo?(mak77)
Comment 4•9 years ago
|
||
I'm marking this as wontfix unless you tell us other major browsers (Edge, Chrome or Sagari) are doing that and it is being used in the wild on some famous site.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•