Admin Forum:Open search results in new tab. JS or CSS?

Is there a way to make search open in a new tab? I hate when it covers up my existing page, and I don't want to have to open up a throwaway page just to use search. This is such a poor design feature of the MediaWiki software.

Anyway, any ideas on how to fix this just for myself with JS or CSS? And what about for a whole wiki? For me personally, I use the Firefox browser. ---Timeshifter (talk) 02:32, March 9, 2012 (UTC)


 * You could use JS to add a target attribute:


 * See here for info about JS files.-- Pecoes 10:31, March 9, 2012 (UTC)


 * Thanks! Works great here:
 * http://community.wikia.com/wiki/User:Timeshifter/global.js


 * That JS and CSS cheat sheet is very helpful. ---Timeshifter (talk) 12:23, March 9, 2012 (UTC)


 * I noticed one problem though. When I search from Special:Search it does not open the search results in a new tab. Can this also be done? ---Timeshifter (talk) 15:20, March 9, 2012 (UTC)


 * That's a different form. This should do it:

-- Pecoes 16:54, March 9, 2012 (UTC)


 * Thanks. I put it here again:
 * http://community.wikia.com/wiki/User:Timeshifter/global.js
 * I substituted this JS code for the other code and it works on the Community Wiki, but only partially on my main wiki, the cannabis wiki. Results of Special:Search opens up in a new tab here, but not on the cannabis wiki:
 * http://cannabis.wikia.com/wiki/Special:Search ---Timeshifter (talk) 07:53, March 10, 2012 (UTC)


 * I just tested it and it worked fine. Were you logged in when you tested this? User:Timeshifter/global.js will work only for you and only as you're logged in. -- Pecoes 08:38, March 10, 2012 (UTC)


 * Yes, I am logged in. Search results open in a new tab here:
 * http://community.wikia.com/wiki/Special:Search
 * but not here:
 * http://cannabis.wikia.com/wiki/Special:Search


 * Maybe it has to do with the JS and CSS Cheatsheet info about the upcoming Special:Mypage/common.js changes? See:
 * http://cannabis.wikia.com/wiki/MediaWiki:Common.js
 * That is working on all skins (Wikia and Monobook) on the Cannabis Wiki. Is anything there interfering with your JS I added here?:
 * http://community.wikia.com/wiki/User:Timeshifter/global.js


 * Also, I am an admin on the cannabis wiki. Maybe that has something to do with it. I don't know. ---Timeshifter (talk) 09:19, March 10, 2012 (UTC)


 * The fact that you're an admin doesn't enter into it and the future functionality of Special:Mypage/common.js is irrelevant now. It should work. It does for me and I'm using the same code. Try to refresh and if that doesn't help purge. -- Pecoes 09:43, March 10, 2012 (UTC)


 * It is working now! Out of curiosity I tried it again without refreshing or purging first. I had already refreshed before. So maybe enough time elapsed since the last time I was here for the server to purge its cache.


 * I added it also to here just now, and did a hard refresh:
 * http://cannabis.wikia.com/wiki/MediaWiki:Common.js
 * I logged out, and search results from both forms open in a new tab. Is this OK to do for a wiki? Does Wikia mind? ---Timeshifter (talk) 13:09, March 10, 2012 (UTC)


 * I can't imagine why they would mind. The rule of thumb seems to be: As long as you obstruct neither ads nor content you can do whatever you like. This little change does neither. -- Pecoes 13:20, March 10, 2012 (UTC)


 * Tagging FAQ. -- Fandyllic (talk &middot; contr) 12 Mar 2012 12:57 PM Pacific

The changes made so far have been greatly useful to me so far. I do many more searches now with Wikia's search engine instead of Google site searches. I use the Firefox browser. Google does not provide a Google Toolbar for Firefox. So previously I was frequently using the Google site searches in the search menu in the Cannabis Wiki. But it was a 2-step process that required opening up a new search tab first. Now I can search immediately from Wikia's search.

There is another problem. When search finds something that matches the search term, then the page opens in the same tab. For example; when the search term comes up in the dropdown list of suggestions. Try searching for "Paris" to see what I mean. It happens when searching for many city names because many cities have pages, and because there are many redirects from the basic city names to the full city+state+nation article title. So if one clicks on an item in the dropdown list of search suggestions then it opens in the same tab.

Special:Search results on the Cannabis Wiki and on the Community Wiki no longer open in a new tab. Maybe all these problems are related. ---Timeshifter (talk) 08:55, March 15, 2012 (UTC)


 * I'm sorry but I can't reproduce your problem. I loaded the exact same code that you have in w:c:cannabis:MediaWiki:Common.js and the exact same code you have in w:User:Timeshifter/global.js and it all worked fine. Do you have code anywhere else? -- Pecoes 17:40, March 15, 2012 (UTC)


 * I am trying to figure it out. Created this as an aid:
 * http://cannabis.wikia.com/wiki/JS_and_CSS_cheatsheet
 * Will take more time, probably tomorrow. ---Timeshifter (talk) 19:12, March 15, 2012 (UTC)

I am wondering how much of this legacy CSS in Common.css is really necessary:
 * http://cannabis.wikia.com/index.php?title=MediaWiki:Common.css&oldid=6322

I am thinking of deleting all of the legacy CSS since it was ignored by Wikia.css unless one made a special effort to import it. See:
 * http://cannabis.wikia.com/index.php?title=MediaWiki:Common.css&action=history

I only want to keep the CSS I added since I know more about what it is for. ---Timeshifter (talk) 22:14, March 15, 2012 (UTC)


 * I looked over the CSS but I have no idea what most of is/was needed for. I'm not exactly an old hand, you know. My MediaWiki/Wikia knowledge is barely two months old...


 * How about the open-search-in-new-page script? Does that work now? I looked over all of your script files and I can't find anything that would conflict with it. The only suggestion I could make is to open your web browser's error console and keep an eye open for JavaScript errors. There's the remote possibility that something else doesn't work and prevents this snippet from working as well. That's all I can think of at any rate. 11:32, March 17, 2012 (UTC)


 * (My fancy new signature almost works now. Sorry for posting all that messy raw code in the other thread!)