• Resolved madeleod

    (@madeleod)


    Hi,
    I am able to open in a new tab, with target=_blank.
    But I would like to open the link into a popup window.
    I put a class to my case 1 in the wp-print.php: class=”popup”
    with a jquery script in the header of my theme

    <script>
    $(‘.popup’).click(function (event) {
    event.preventDefault();
    window.open($(this).attr(“href”), “popupWindow”, “width=600,height=600,scrollbars=yes”);
    });
    </script>

    Unfortunately, it doesn’t work.
    Any idea?
    Thanks in advance.
    Made

    https://wordpress.org/plugins/wp-print/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Lester Chan

    (@gamerz)

    Can I see you webpage with the code?

    Thread Starter madeleod

    (@madeleod)

    Thx for your response.
    I found the solution this night 😉 and now it works!
    Here is the good one:

    <script>
    jQuery(document).ready(function($) {
        jQuery('a.popup').live('click', function(){
            newwindow=window.open($(this).attr('href'),'','height=600,width=600');
            if (window.focus) {newwindow.focus()}
            return false;
        });
    });
    </script>

    Made

    Made,

    Thanks for this – just what I was thinking of doing so you saved me some effort. Unfortunately, your change will get overwritten with any plugin update. Since I am manually changing my theme’s single.php file (via a child theme), I decided to use a php str_replace command to accomplish the same thing you did. Here is my code:

    if(function_exists('wp_print')) {
    	$temp = print_link("","",false);
    	$temp = str_replace ('title="Print This Post" rel="nofollow"', 'title="Print This Article" rel="nofollow" class="popup"', $temp);
    	echo $temp;
    }

    Note that you will have to modify the search text you choose to replace based on your circumstances (for example, you are using the icon and text option, where I use the icon only option; also, if you changed the default print text in the options page you won’t be choosing “Print This Post”). Hope this helps someone else who might come across this thread.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘open in a popupwindow’ is closed to new replies.