• I added target=”_blank” to every “a href” I could find in the plugin to try to make links I post in Twitter open in a new window, but it’s not working. Anyone know how to do this?

Viewing 1 replies (of 1 total)
  • Since opening a new window is consider a behavior. It’s best to create this functionality with JavaScript.

    I like using the jquery library. So here is how you would do it with jquery. Make sure to link to you jquery library file in the head of your document.

    Next I like to use an initiate.js to place all my ‘working’ javascript into. In this file paste:

    $(document).ready( function() {
    		$('.twitter-link').addClass('extlink');
    		$('.extlink').click( function() {
            window.open( $(this).attr('href') );
            return false;
        });
    });

    The Twitter for WordPress plugin automatically adds the class twitter-link to every link. So then I’m just using that as a selector to add another class called extlink to all links that already has a class of twitter-link. Any link that has a class of extlink will now open in a new window.

    You could just directly apply the the window.open directly to twitter-link, but by doing it as I have done above you can now add .extlink to any link anywhere in you blog. For example in a post or a page.

    Hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Twitter for WordPress] Opening links in new window’ is closed to new replies.