How do I make this reddit widget open it's links up into new tab?

755 Views Asked by At

Here is the Reddit widget code:

I'd like for every clickable link in the reddit widget box to open up into a new tab. Any idea of how to do this? Thanks For all your help!

2

There are 2 best solutions below

1
On

You could try adding the target="_blank" attribute to each link in the widget with jquery.

$(document).ready(function(){
    $('.rembeddit a').each(function(){
        $(this).attr('target', '_blank');
    });
});
0
On

So, for example, reddit generates this for you for a widget code. The problem is that it will open any links in the same window.

<script src="http://www.reddit.com/r/satire/hot/.embed?limit=5&t=all" type="text/javascript"></script>

You can make it open in a new tab/window (based on browser settings) by adding &target=blank :

<script src="http://www.reddit.com/r/satire/hot/.embed?limit=5&t=all&style=off&target=blank" type="text/javascript"></script>

Adding the bolded script seems to do the trick just fine.