How to link inside a specific jquery tab?

bookmarklet for a random link in a new tab

  • In Firefox, how can I get my bookmarklet to open a link in a new tab? I'm looking for a bookmarklet that will open a random link on the current page, in a new tab. I found a couple of random link openers: javascript:void(window.open(document.links[Math.floor(Math.random()*document.links.length)].href,'_self')); javascript:void(location.href=document.links[Math.floor((document.links.length)*Math.random())]) but both of them just open the link in the same tab I'm in. Is there a way to modify either of these to open new tabs, or, alternatively, some other one-click way to open a randomly selected link?

  • Answer:

    take the '_self' bit off the first one, or change it to a different name. _self refers to the current window anything else (except '_parent' or '_top' which also do special things), or nothing, will mean it opens in a new window.

maqsarian at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Other answers

you want '_blank' instead of '_self' in the first one.

jedrek

In the second one, change "void(location.href=blah)" to "void(window.open(blah,'_blank'))".

mbrubeck

Sweet. Thanks!

maqsarian

Middle-clicking on a three button mouse opens bookmarks and normal links in a new tab. On my 2-button laptop, chording the buttons (pushing and releasing both buttons together) is interpreted as a middle button press and does the same thing.

NortonDC

Yes. Middle-clicking on a bookmarklet, though, just opens a new tab to javascript:whatever.

maqsarian

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.