MediaWiki talk:Search-results-new-tab.js
Note. This JS is no longer working right. It not only automatically opens the search results list in a new tab as it should. It also opens it in the same tab. So it is creating 2 search result pages. It shouldn't be doing that. --Timeshifter (talk) 14:06, 5 December 2013 (UTC)
Makes search results open in a new tab automatically (if the browser supports it). To use, add
|
Note: 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.
- #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.
- There is also a JS (JavaScript) import that uses Ctrl-click (PC) and Command-click (Mac) to open search result lists and suggestions in a new tab. See: MediaWiki talk:Gadget-search-new-tab.js
Problem with advanced search. Fixed
[edit]See this discussion about a problem with advanced search on Wikia, and the solution:
I see the same problem here on the Commons too. Also on Wikipedia:
- http://en.wikipedia.org/w/index.php?title=User:Timeshifter/common.js&oldid=483939733 --Timeshifter (talk) 06:43, 30 March 2012 (UTC)
- Thanks for fixing the problem, Rd232! --Timeshifter (talk) 07:45, 31 March 2012 (UTC)
- For the record, the addition of #powersearch fixed the problem. See diff of March 30, 2012 change. So searches with the advanced search button at Special:Search also open in new tabs. This is after one clicks the advanced search link to get the dropdown of search choices. Then when one clicks the search button the results open in a new tab. --Timeshifter (talk) 03:58, 25 July 2012 (UTC)
Can import into any-language Wikipedia
[edit]For those who are interested this works on Wikipedia too. Copy and paste Import the JavaScript (JS) directly into here:
- en:Special:MyPage/common.js - for me that ends up here: en:User:Timeshifter/common.js
The above links are for English Wikipedia. Change the links as necessary for other-language Wikipedias. Remember to copy import the JS directly from MediaWiki:Search-results-new-tab.js
Importing does not seem to work from the Commons to Wikipedia. --Timeshifter (talk) 08:32, 9 April 2012 (UTC)
- Importing is different when it's not on the local site. I fixed it for you in this edit. Killiondude (talk) 20:17, 5 May 2012 (UTC)
- The function
importScriptURI
was deprecated on MW 1.17 (the current version is 1.20wmf2). Please usemw.loader.load
instead. Helder 20:29, 5 May 2012 (UTC)
- The function
Helder. This is working for me on Wikipedia at en:User:Timeshifter/common.js:
importScriptURI('//commons.wikimedia.org/w/index.php?title=MediaWiki:Search-results-new-tab.js&action=raw&ctype=text/javascript');
What exactly should I be using instead? --Timeshifter (talk) 20:44, 5 May 2012 (UTC)
- Thanks to User:Killiondude for telling me what exactly to use! Here is what people can add to en:Special:MyPage/common.js:
/* Open search results list and search suggestions in new browser tab */ /* commons.wikimedia.org/wiki/MediaWiki_talk:Search-results-new-tab.js */ mw.loader.load('//commons.wikimedia.org/w/index.php?title=MediaWiki:Search-results-new-tab.js&action=raw&ctype=text/javascript');
mw.loader.load
was substituted forimportScriptURI
- For more info: mw:RL/DM#mediaWiki.loader --Timeshifter (talk) 06:16, 8 May 2012 (UTC)
Discussions elsewhere for opening search result lists and suggestions in new tabs
[edit]I proposed a gadget (in preferences) for opening search results and suggestions in new tabs. See:
- Commons:Village_pump/Proposals/Archive/2012/04#Open_search_results_and_suggestions_in_new_tabs
- en:Wikipedia:Gadget/proposals#Open search result list or search suggestion in a new tab
- en:Wikipedia:Village pump (technical)/Archive 99#Preference for opening search result list or search suggestion in new tab
I suggested basing it on the JavaScript from here:
Bug
[edit]See here. Helder 14:03, 12 April 2012 (UTC)
- I think that's a bug in Chrome. All the script does is put
target: '_blank'
on the relevant links; if Chrome opens a new tab in the way you described, that's Chrome's choice. At any rate, even if it's possible to accommodate Chrome by changing the script, I've not the faintest idea how. Rd232 (talk) 14:52, 12 April 2012 (UTC)- Oh well.. I've disabled it for now :-( Helder 12:54, 16 April 2012 (UTC)
MediaWiki gadget, preference, or default setting
[edit]I started this Bugzilla thread: "Bug 35974 - Preference or default setting to open search results and suggestions in new tab".
- https://bugzilla.wikimedia.org/show_bug.cgi?id=35974 --Timeshifter (talk) 16:18, 14 April 2012 (UTC)
- I also started a discussion here:
- http://www.mediawiki.org/wiki/Gadget_kitchen/Requests --Timeshifter (talk) 23:54, 14 April 2012 (UTC)
Listed this search enhancement at Help:Searching
[edit]I linked to this page from Help:Searching. I also explained how to get this to work on Wikipedia at en:Help:Searching. --Timeshifter (talk) 11:10, 25 April 2012 (UTC)
Opening archive search result lists in new tabs
[edit]Try the archive search forms found on these pages:
They open in the same tab. --Timeshifter (talk) 20:11, 31 May 2012 (UTC)
- A solution has been provided by User:Rd232. See User talk:Rd232#Archive searches do not open in new tabs. This works:
/* Open search result lists and suggestions in new browser tabs */ $(function () { $('#searchform, #search, #powersearch, #searchbox, .search-types, #search-types').attr({ target: '_blank' }); });
- The only change to the JS is the addition of #searchbox. --Timeshifter (talk) 04:56, 2 July 2012 (UTC)
- Done Rd232 (talk) 07:05, 2 July 2012 (UTC)
- Thanks! --Timeshifter (talk) 09:59, 3 July 2012 (UTC)
- Done Rd232 (talk) 07:05, 2 July 2012 (UTC)