MediaWiki talk:Gadget-search-new-tab.js

Latest comment: 11 years ago by Timeshifter in topic Browsers


In all search forms this makes the search result list or search suggestion open in a new tab via Ctrl-click (PC) and Command-click (Mac). Ctrl (PC) or  Command (Mac). Users can import the JavaScript (JS) into other wikis outside the Commons. In English Wikipedia it can be enabled in "my preferences" here: en:Special:Preferences#mw-prefsection-gadgets in the browsing section at the top.

// Ctrl-click (PC) and Command-click (Mac) to open search in new tab.
// The Command key is the Apple key on Apple keyboards.
// commons.wikimedia.org/wiki/MediaWiki_talk:Gadget-search-new-tab.js
// On the Commons enable the gadget in your preferences. On other wikis...
// Add line below to Special:MyPage/common.js (User:YOUR-USER-NAME/common.js)

mw.loader.load('//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-search-new-tab.js&action=raw&ctype=text/javascript');

Add to mw:Special:MyPage/common.js, or other-language Wikipedias, or other Wikimedia projects. Some examples: mw:User:Timeshifter/common.js. The lines starting with // are notes, and are optional.

Notes: Here are the component parts and what they effect:

#searchform - embedded search form at top right of every page.
#searchbox - embedded archive search forms. For example; Template:Village pump archives, Commons:Village pump/Proposals/Header, and Commons:Village pump/Header.
#search, .search-types, #search-types - Special:Search.
#powersearch - advanced search at Special:Search. This is after one clicks the advanced search link at Special:Search to get the dropdown of search choices. Then when one clicks the search button #powersearch applies to it.
Most browsers open (or can be set to open) any normal link in a new tab via ctrl-click (PC) and command-click (Mac). So this JavaScript (JS) import does the same thing for search submit buttons.
On any empty search form you can now ctrl-click or command-click the submit button to get to Special:Search, or a variation of it, in a new tab.
There is also a JS import that automatically opens search in a new tab. See: MediaWiki talk:Search-results-new-tab.js
See also: en:Help:Searching and en:Wikipedia:WikiProject User scripts/Scripts#Search.

Discussion elsewhere edit

Note. Feel free to add more links.

Commons edit

Bugzilla edit

See en:WP:Bugzilla for more info.
  • Bugzilla:35974. Preference or default setting to open search result lists in new tab via Ctrl-click
  • Bugzilla:17808. Have search suggest results open in a new tab on middle click.
  • Bugzilla:34756. SimpleSearch should use native event handling (open link in or submit form to a new tab).
  • Bugzilla:29448. Add "advanced search" link in the search drop down.

English Wikipedia edit

Browsers edit

Testing browsers. Here is a page outside Wikimedia with a search form at the top:

Chrome allows one to Ctrl-click the form submit button to open the results list in a new tab. Shift-click to open the results list in a new window.

Firefox and Internet Explorer do not allow one to send the form results list to a new tab or window by ctrl-click, shift-click, middle click, right click, etc.. The Firefox developers are not going to add this ability. See comments 124 and 151 in this thread:

So this gadget preference is needed for Firefox and Internet Explorer. --Timeshifter (talk) 14:33, 29 January 2013 (UTC)Reply

Return to "Gadget-search-new-tab.js" page.