How to Open External Links in New Window in WordPress

Posted on 7th Jun, 2011 in jQuery Snippets

Here is very simple way to open external URL links in new window or tab in WordPress using the jQuery library. Just copy & paste the following code somewhere between your head tags.

<script src="" type="text/javascript"></script>
<script type="text/javascript">
        $("body a[href^='http://']").not("body [href*='']").attr('target','_blank');

This link will open in new window & this will not.